Skip to content

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

Closed
@egonk

Description

@egonk

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeHelpWantedIssues that are not prioritized by the maintainers. Help is requested from community contributors.NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions