Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inferGopath gets disabled if a vendored package is using modules #301

Closed
egonk opened this issue Jul 8, 2020 · 2 comments
Closed

inferGopath gets disabled if a vendored package is using modules #301

egonk opened this issue Jul 8, 2020 · 2 comments
Labels
FrozenDueToAge HelpWanted Issues that are not prioritized by the maintainers. Help is requested from community contributors. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@egonk
Copy link

egonk commented Jul 8, 2020

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go version go1.14.4 windows/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 1.46.1 cd9ea6488829f560dc949a8b2fb789f3cdc05f5d x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.15.1
  • Run go env to get the go development environment details
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\egon\AppData\Local\go-build
set GOENV=C:\Users\egon\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\egon\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\egon\AppData\Local\Temp\go-build982835902=/tmp/go-build -gno-record-gcc-switches

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

    "go.inferGopath": true,
    "go.toolsGopath": "c:\\gotools",
    "go.lintOnSave": "off"

Describe the bug + Steps to reproduce the behavior

I have a project structure like this: src/a/b/c and multiple vendored packages in src/a/b/c/vendor/.... Some of the vendored packages have a go.mod file. There are no other go.mod files. When I open a file src/a/b/c/vendor/d/e.go, inferGopath gets disabled and effectively everything stops working (code completion, ...).

This is the commit that causes the problem: 49c5123

I would expect a less drastic approach in this case:

  • skip the check if '/vendor/' is in path, or
  • notify the user politely like gopls:
    promptToUpdateToolForModules('gopls', promptMsg, goConfig);
@hyangah
Copy link
Contributor

hyangah commented Jul 8, 2020

@egonk Thanks for the report and also investigating the root cause.

I think checking /vendor/ and exclude them from the decision seems like a reasonable hack.
Contribution is welcome!

--

As Go is moving away from GOPATH and migrating towards the go modules mode
where GOPATH is no longer a place to host source code, I think it's time to think about
what to do with this setting. #186 is tracking this effort.

@hyangah hyangah added HelpWanted Issues that are not prioritized by the maintainers. Help is requested from community contributors. NeedsFix The path to resolution is known, but the work has not been done. labels Jul 8, 2020
@hyangah hyangah added this to the Backlog milestone Aug 7, 2020
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/260658 mentions this issue: src/goModules: exclude vendor paths from inferGopath disable mechanism

@hyangah hyangah modified the milestones: Backlog, v0.18.0 Oct 21, 2020
@golang golang locked and limited conversation to collaborators Oct 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge HelpWanted Issues that are not prioritized by the maintainers. Help is requested from community contributors. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants