I have installed the Go extension (version 0.11.4) in Visual Studio Code on MacOS:
However, I find that the linter does not 'pick up' functions defined in the same package, but in different files. For example, if I create in the same directory a file foo.go
with
package foobar
import "fmt"
func main() {
fmt.Println(SayHello())
}
and a file bar.go
with
package foobar
func SayHello() string {
return "Hello, world!"
}
then in foo.go
I get a linter error that SayHello
is an undeclared name
:
I've read about a similar issue here (https://github.com/golang/lint/issues/57), but since that issue is five years old I figured it might be fixed by now? Or does golint
simply not work across multiple files?
Update VS Code Go Tool might help. Command + Shift + P
-> Go: Install/update tools
Install all tools and restart VS Code.
Make clean uninstall of vscode and then it's work fine again...
add sudo if you needed to
rm -rf $HOME/Library/Application\ Support/Code
rm -rf $HOME/.vscode
remove vscode from application
download vscode and install again