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
Comment From: gabyhelp
Related Issues
- x/tools/gopls: can't find definition using -mod=mod #73492
- x/tools/gopls: Add refactor "move to a new file" #65707 (closed)
- x/tools/gopls: gopls completes a function from an unimported module in the vendor path but uses an incorrect import path with "vendor/" #71474
- x/tools/gopls: Revert the changes from the last refactor. #70610 (closed)
- x/tools/gopls: workspace symbols jumps to incorrect location with files with CGO #37659 (closed)
- x/tools/gopls: Show specific file name when renaming failed. #69563 (closed)
- x/tools/gopls: add a regression test for adding a new function to a replace target #40712
- x/tools/gopls: Error due to trying to respect transient replace #44622 (closed)
- x/tools/gopls: Cannot jump to definitions in k8s stage dir #60841 (closed)
- x/tools/gopls: gopls doc viewer failed with "package not found" error #70453 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: madelinekalil
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?
Comment From: hedongyouxia
@madelinekalil I do this with your suggestion,and it show the origin pkg but not the replaced pkg.eg:
Comment From: madelinekalil
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.
Comment From: hedongyouxia
@madelinekalil I do it again,and it show as follows:
Comment From: madelinekalil
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.
Comment From: hedongyouxia
@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:
According to the results in the picture, only the go list after setting -mod=mod will output the real replaced module, but if we use gopls to find the reference of a function at this time, many things will be missing.I example it at the issues what happend with set -mod=mod
Comment From: jba
/cc @matloob