AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 351 forks source link

Cannot install/import using go get -u github.com/AlecAivazis/survey/v2, compilerBrokenImport #391

Closed stevelizcano closed 2 years ago

stevelizcano commented 2 years ago

What operating system and terminal are you using? MacOS 12.0.1 Monterey An example that showcases the bug.

➜  ptx-ctl git:(master) ✗ go get -u github.com/AlecAivazis/survey/v2
go: downloading github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
go: downloading golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
go get: added github.com/AlecAivazis/survey/v2 v2.3.2
go get: added github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
go get: added github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
go get: upgraded golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 => v0.0.0-20210927222741-03fcf44c2211

And then when using it the following error occurs:

could not import github.com/AlecAivazis/survey/v2 (no required module provides package "github.com/AlecAivazis/survey/v2")compilerBrokenImport

What did you expect to see?

Import working

What did you see instead?

could not import github.com/AlecAivazis/survey/v2 (no required module provides package "github.com/AlecAivazis/survey/v2")compilerBrokenImport
mislav commented 2 years ago

Hi, I'm not sure why you get that error, but I can assure you that the module configuration of this library is in order. I just tried with go 1.17:

/tmp $ mkdir survey-test

/tmp $ cd survey-test

/tmp/survey-test $ go mod init github.com/mislav/survey-test
go: creating new go.mod: module github.com/mislav/survey-test

/tmp/survey-test $ go get -u github.com/AlecAivazis/survey/v2
go: downloading golang.org/x/text v0.3.7
go: downloading golang.org/x/sys v0.0.0-20211124211545-fe61309f8881
go get: added github.com/AlecAivazis/survey/v2 v2.3.2
go get: added github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
go get: added github.com/mattn/go-colorable v0.1.12
go get: added github.com/mattn/go-isatty v0.0.14
go get: added github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d
go get: added golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6
go get: added golang.org/x/term v0.0.0-20210503060354-a79de5458b56
go get: added golang.org/x/text v0.3.3

/tmp/survey-test $ cat go.mod
module github.com/mislav/survey-test

go 1.17

require (
        github.com/AlecAivazis/survey/v2 v2.3.2 // indirect
        github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
        github.com/mattn/go-colorable v0.1.12 // indirect
        github.com/mattn/go-isatty v0.0.14 // indirect
        github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
        golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 // indirect
        golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
        golang.org/x/text v0.3.3 // indirect
)

/tmp/survey-test $ cat main.go
package main

import _ "github.com/AlecAivazis/survey/v2"

func main() {
}

/tmp/survey-test $ go build main.go

/tmp/survey-test $ ./main
[no errors]

It might be that something regarding modules in your app is broken; perhaps an out-of-date vendor directory? Anyway, I'm going to close this, because this looks like an app-specific problem rather than a problem with this library.

stevelizcano commented 2 years ago

Thanks @mislav , I double checked and I think it was a go mod vendor problem. Thanks for checking!