Skip to content

x/tools/gopls: pkg is not in your go.mod file error when run with GOPRIVATE or GONOSUM & GONOPROXY envs #75075

@krhubert

Description

@krhubert

Go version

go1.25

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE='auto'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV=''
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3716859692=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/user/src/krhubert/goclean/shared/go.mod'
GOMODCACHE='/home/user/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/user/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/user/pkg/mod/golang.org/[email protected]/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.0'
GOWORK='/home/user/src/krhubert/goclean/go.work'
PKG_CONFIG='pkg-config'

What did you do?

Run gopls check on go files

$ gopls check ./golden/golden.go
$ GOPRIVATE='github.com/krhubert/goclean/*' gopls check ./golden/golden.go
/home/user/src/krhubert/goclean/shared/golden/golden.go:1:1-50: github.com/krhubert/goclean/shared is not in your go.mod file
/home/user/src/krhubert/goclean/shared/golden/golden.go:35:2-47: github.com/krhubert/goclean/shared is not in your go.mod file
$ GONOPROXY='github.com/krhubert/goclean/*' gopls check ./golden/golden.go
$ GONOSUMDB='github.com/krhubert/goclean/*' gopls check ./golden/golden.go
$ GONOPROXY='github.com/krhubert/goclean/*' GONOSUMDB='github.com/krhubert/goclean/*' gopls check ./golden/golden.go
/home/user/src/krhubert/goclean/shared/golden/golden.go:1:1-50: github.com/krhubert/goclean/shared is not in your go.mod file
/home/user/src/krhubert/goclean/shared/golden/golden.go:36:2-50: github.com/krhubert/goclean/shared is not in your go.mod file

What did you see happen?

Errors when invoked with either GOPRIVATE or GONOSUMDB/GONOPROXY envs

What did you expect to see?

No errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolProposalIssues describing a requested change to a Go tool or command-line program.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions