-
Notifications
You must be signed in to change notification settings - Fork 645
'Build on save' fails for module-enabled package inside GOPATH #2238
Comments
Thanks for reporting this @nezorflame! And apologies for not getting to this sooner. We try to deduce the import path of a package based on the folder path and the GOPATH it is under. But when using modules under GOPATH, as you have shown this will not yield the right import path for the package. When fixing this, I noticed that 2 other features (debugging and the I have pushed a fix for all of this, would you mind giving the latest beta version of this extension a try? |
Thanks @ramya-rao-a! I'll try this today and will let you know. |
Yup, seems to work well. |
Hello, |
@qjerome there wasn't a release yet, use latest beta. |
awesome, thanks |
The fix for this issue is out in the latest release(0.10.0) of the Go extension |
Setup
Env
GO111MODULE
:on
Working directory
$GOPATH/src/test-project
Project layout
File contents
./test.go:
./go.mod:
cmd/test/main.go:
cmd/test/go.mod:
The problem
When trying to check for package errors with
Build on save
action inside thetest.go
, I get an error:[go] can't load package: package test-project: unknown import path "test-project": cannot find module providing package test-project
Same happens with the
cmd/test/main.go
:[go] can't load package: package test-project/cmd/test: unknown import path "test-project/cmd/test": cannot find module providing package test-project/cmd/test
Command output:
/Users/nezorflame/Go/src/test-project/cmd/test>Finished running tool: /Users/nezorflame/.gvm/gos/go1.11.4/bin/go build -o /var/folders/j3/c8l_b0nj4w5b6zmrgx3z755c0000gp/T/vscode-goXfH5T2/go-code-check test-project/cmd/test can't load package: package test-project/cmd/test: unknown import path "test-project/cmd/test": cannot find module providing package test-project/cmd/test
The error text and command output indicates that
Build on save
action detected that my package is inside$GOPATH
(which is correct), but it uses relative pathtest-project/cmd/test
instead of absolute path.Suggestion on how to fix it
From my experiments, it seems that using the absolute path fixes the issue:
The text was updated successfully, but these errors were encountered: