Description
gopls version
golang.org/x/tools/gopls v0.18.1
go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/didi/Library/Caches/go-build'
GOENV='/Users/didi/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/didi/WorkSpace/gopath/pkg/mod'
GONOPROXY='git.xiaojukeji.com'
GONOSUMDB='git.xiaojukeji.com'
GOOS='darwin'
GOPATH='/Users/didi/WorkSpace/gopath'
GOPRIVATE='git.xiaojukeji.com'
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.12'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/v4/7ds055qn1v36dxgvzj88xxmh0000ks/T/go-build4148190690=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
I use vocode with gopls to read kubernetes code,there are some replace pkg in go mod,and when i to find some function which define,it also redirect the vendor code but not the replaced pkg.If i need change some code,i also to find the realy replaced pkg which the function to be defined.
What did you see happen?
such as this because the code is replaced to staging code in the go mod file,but when i use gopls,it redirect to vendor code but the really staging code.If i need change the code something,i need to also to get the really place in the staging.
in go mod file,the picture pkg is replaced to staging pkg code,but the gopls is not correct redircet.
the picture code really pkg is staging file.
What did you expect to see?
I expect when some pkg to be replaced local pkg,can gopls support jumping to the actual code location after replaced by local code pkg.
Editor and settings
No response
Logs
No response
Activity
[-]x/tools/gopls: can support really pkg redirect[/-][+]x/tools/gopls: go to definition should go to replaced version of module[/+]gabyhelp commentedon Apr 30, 2025
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
madelinekalil commentedon May 8, 2025
Can you please run
go list -m -f={{.Dir}}
for one of the modules that you have a replace directive for and see what the output is?hedongyouxia commentedon May 9, 2025
@madelinekalil I do this with your suggestion,and it show the origin pkg but not the replaced pkg.eg:
madelinekalil commentedon May 9, 2025
Sorry, the exact command you should run is
go list -m -f={{.Dir}} k8s.io/client-go
(or replace k8s.io/client-go with another module you have a replace directive for.) The -f={{.Dir}} is formatting the output and should not be modified.hedongyouxia commentedon May 9, 2025
@madelinekalil I do it again,and it show as follows:
madelinekalil commentedon May 9, 2025
Oops, it should be "client-go" instead of "client.go". If go list cannot find this module then it will explain why the go to definition is not finding the replaced version of the module.
hedongyouxia commentedon May 10, 2025
@madelinekalil I apologize for the repeated error and I am very grateful for your patient explanation. I re-executed go list and compared the changes before and after the setting -mod=mod, and the output content is as follows: