Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 98825

Go linter in VS code not working for packages across multiple files?

$
0
0

I have installed the Go extension (version 0.11.4) in Visual Studio Code on MacOS:

enter image description here

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:

enter image description here

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?


Viewing all articles
Browse latest Browse all 98825

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>