This problem will happen when go cannot find your other file (like lib.go
in this example).
If you use JetBrains Goland , you should change your "Run kind" to "Directory". Goland will help you to do these:
go build .
- run this execution file.
If you use JetBrains Goland , you can contrast the difference between "Run kind".
When i select "File", and then run, you will see the message on the console, like this:
GOROOT=C:\Go #gosetup
GOPATH=C:\Users\hgs\go #gosetup
C:\Go\bin\go.exe build -o C:\Users\hgs\AppData\Local\Temp\___go_build_select_go__4_.exe "C:/Users/hgs/Google Drive/My Maps/computer/2.programming_lang/Golang/source-code-refer/basic/select.go" #gosetup
# command-line-arguments
.\select.go:14:16: undefined: Add
When you select "Directory" and select your directory, and then run, you will see something like this:
GOROOT=C:\Go #gosetup
GOPATH=C:\Users\hgs\go #gosetup
C:\Go\bin\go.exe build -o C:\Users\hgs\AppData\Local\Temp\___go_build_basic_.exe . #gosetup
C:\Users\hgs\AppData\Local\Temp\___go_build_basic_.exe #gosetup
...