-
Notifications
You must be signed in to change notification settings - Fork 646
Editor breaks import path when Go module replacements are used #2572
Comments
Please share any Go related settings you might have added/edited |
There is only
If you need anything else please let me know. |
I believe I'm experiencing the same problem. Check out this sample repro solution: https://github.com/chgeuer/repo-go-mod-vs-code There are two VS Code workspaces, called "good" and "bad". The "good" one only shows the main folder, while "bad" shows everything. I would love to open "bad", but then the whole F12 navigation etc doesn't work any longer.
My global VS Code settings ( {
"go.useLanguageServer": true,
"go.vetOnSave": "workspace",
"go.docsTool": "gogetdoc",
"go.enableCodeLens": {
"references": false,
"runtest": true
}
} |
ping @ramya-rao-a is there anything else we could contribute? |
Hi @andig, apologies for the late reply. Your settings show that you are not using the language server. @chgeuer Can you share your settings as well? In the absence of the language feature, the tool specified in @andig Can you add the below in your settings to disable the format on save feature and see if you still see the issue? This can confirm if the formatting is indeed making this change
|
Thank you @ramya-rao-a. I wasn‘t aware that I needed to manually enable the language server istead of this being the default (I haven‘t touched the config at all). Reading https://github.com/Microsoft/vscode-go/wiki/Go-modules-support-in-Visual-Studio-Code shows I‘ll need to add a setting. I will test both your suggestion and using the language server. Update regarding 1) just realized that the language server apparently can't be used inside workspaces as the setting can't be applied. |
Hi @ramya-rao-a I updated by comment above |
I can no longer reproduce this when not using the language server (i.e. inside a workspace). Instead now, my import |
The language server doesnt work with workspaces. There is a known issue tracking that. |
|
At least in my case thats the setup I have. Above issue has been fixed for me by getting rid of the replace statement. |
@stamblerre Is there anything that can be done for this issue? From what I understand @andig resolved the situation by removing the replace statement entirely |
What @andig is describing sounds like an issue with an old version of |
Thanks @stamblerre Closing this issue. If the problem still persists with the new version of the Go tools, please log a new issue |
My code contains various imports:
I'm also using the types imported from
gosunspec
inmain.go
:Using
go.mod
, I have to temporarily replacecrabmusket/gosunspec
with a custom fork until an upstream issue is resolved:Now, when editing
main.go
, two things are happening:"github.com/crabmusket/gosunspec"
import into the"github.com/andig/gosunspec"
replacement"github.com/andig/gosunspec"
is added togo.mod
(I assume rather by go than by vscode)Synopsis if types are part of a replacement package, import path must match the replaced package instead of the replacement package.
Full source is available in https://github.com/andig/mbmd/blob/scan-sunspec/cmd/scan/main.go
The text was updated successfully, but these errors were encountered: