Skip to content

x/tools/gopls: documentation, error messages, and mod tidy behavior can make adding a dependency confusing #60935

@p3tr0v

Description

@p3tr0v

What version of Go are you using (go version)?

$ go version
go version go1.20.5 windows/amd64
go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\user\AppData\Local\go-build
set GOENV=C:\Users\user\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\dev\projects\golang\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\dev\projects\golang
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\dev\Go\1.20.5
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\dev\Go\1.20.5\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=C:\dev\projects\golang\src\projX\subProjX\go.mod
set GOWORK=C:\dev\projects\golang\src\go.work
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\user\AppData\Local\Temp\go-build1680866235=/tmp/go-build -gno-record-gcc-switches

What did you do?

I installed all my Go dev environment from zero, by Go 1.20
I set my GOPATH as env above, then I set my go.work file on the root from my workspace, like the official ref says to do.
After typing "go get github.com/any/module/example", the project are downloaded to GOMODCACHE but Golang says that "could not find the package", and I just ask "why???"
It really uncomfortable when you follow the official reference and this happen, seems that Google engineers don't understand how workspace and dependency works, and I really don't wanna believe on it.

What did you expect to see?

I expect see golang finding the packages after "go get"

What did you see instead?

Golang cant find the packages under his own structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/metadataIssues related to metadata loading in gopls

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions