VS Code dosn't see the package

I imported “gin-gonic/gin” package in my project, but VS code doesn’t see it in GOPATH or GOROOT. How to fix it? These my GOPATH and GOROOT:
GOPATH: “C:\Users\agl\go\pkg\mod\github.com”
GOROOT: “C:\Program Files\Go”
As far as I know, only standard packages should be in GOROOT.

It should just work within a properly set up go module. Do you have a go.mod and go.sum?

Or are you consciously working in a “legacy” environment using the GOPATH?

If that is the case you will need to set up VScode to adhere to the GOPATH that is valid for the project and you also need to make sure that it contains all the libraries you need.

I haven’t used legacy workspaces since modules have been available as a pre-release feature and am therefore not sure about what steps are necessary to set them up.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.