You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having trouble setting up a Golang project to work with the Golang extension in VSCode. I have followed the instructions for setting up a Golang project and have been able to build and test my project successfully using the command line (go build and go test ./...). However, the Golang extension in VSCode is giving me an error when I try to import a package (gonum.org/v1/gonum/mat). The error message says that the package cannot be found in either $GOROOT or $GOPATH, but I have confirmed that the package is installed under $GOPATH/pkg/mod/gonum.org/v1/[email protected]/mat. Additionally, the Golang extension does not seem to recognize my project and I am unable to run tests or use other features of the extension.
Steps to reproduce
Install the Golang extension v0.38.0 in VSCode.
Create a new Golang project with the following directory structure:
Open the my_project directory in VSCode and attempt to run tests using the VSCode test runner or use other features of the Golang extension.
Expected behavior
The Golang extension should recognize the project and allow me to run tests and use other features of the extension. The package gonum.org/v1/gonum/mat should be found and able to be imported.
Actual behavior
The Golang extension does not recognize the project and I am unable to run tests or use other features of the extension. The package gonum.org/v1/gonum/mat cannot be found and gives an error when trying to import.
Hi @dsm-72 this is currently a limitation of gopls' workspace detection. You will need to either open the PackageName directory in your example, or use a go.work file to tell gopls which modules you are working on.
We're in the process of improving this workflow, in golang/go#57979.
Issue description
I am having trouble setting up a Golang project to work with the Golang extension in VSCode. I have followed the instructions for setting up a Golang project and have been able to build and test my project successfully using the command line (
go build
andgo test ./...
). However, the Golang extension in VSCode is giving me an error when I try to import a package (gonum.org/v1/gonum/mat
). The error message says that the package cannot be found in either$GOROOT
or$GOPATH
, but I have confirmed that the package is installed under$GOPATH/pkg/mod/gonum.org/v1/[email protected]/mat
. Additionally, the Golang extension does not seem to recognize my project and I am unable to run tests or use other features of the extension.Steps to reproduce
Install the Golang extension v0.38.0 in VSCode.
Create a new Golang project with the following directory structure:
Add the following contents to the
go.mod
file:Note:
go get gonum.org/v1/gonum/mat
andgo get -u gonum.org/v1/gonum/mat
results inrequire gonum.org/v1/gonum v0.13.0
Add the following contents to the
main.go
file:Add the following contents to the
subpkg/subpkg.go
file:my_project
directory in VSCode and attempt to run tests using the VSCode test runner or use other features of the Golang extension.Expected behavior
The Golang extension should recognize the project and allow me to run tests and use other features of the extension. The package
gonum.org/v1/gonum/mat
should be found and able to be imported.Actual behavior
The Golang extension does not recognize the project and I am unable to run tests or use other features of the extension. The package
gonum.org/v1/gonum/mat
cannot be found and gives an error when trying to import.System information
Ventura 13.3.1 (a)
version:1.78.0 arm64
go version go1.20.4 darwin/arm64
$GOPATH
environment variable:/Users/USER/go/
$GOROOT
environment variable:/opt/homebrew/opt/go/libexec
Additional information
go version
command:go version go1.20.4 darwin/arm64
go env
command:The text was updated successfully, but these errors were encountered: