Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: Cannot navigate to function on MacOS when the go file is Windows OS specific. #67646

Closed
wayneforrest opened this issue May 25, 2024 · 2 comments
Labels
gopls/metadata Issues related to metadata loading in gopls gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@wayneforrest
Copy link

Go version

go version go1.22.3 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN='/Users/wayneforrest/go/bin'
GOCACHE='/Users/wayneforrest/Library/Caches/go-build'
GOENV='/Users/wayneforrest/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/wayneforrest/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/wayneforrest/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/wayneforrest/Documents/Projects/nextup/nextup-lib/go.mod'
GOWORK='/Users/wayneforrest/Documents/Projects/nextup/nextup-lib/go.work'
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/40/h2gz12596h37pwhss5_bsqdh0000gn/T/go-build392454702=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Edit a "windows" file (platform specific) .. main_windows.go on MacOS Arm64 / M1.

I have two files, main_darwin.go and main_windows.go that serve two purposes, the Darwin one is for testing the code on MacOS, while the windows one is what will ultimately ship and be packaged.

When editing the main_windows.go file I am unable to navigate to symbol / function using VsCode.

What did you see happen?

When navigating to a symbol by pressing F12, I get the message No definition found for FatalF.

I notice this stack trace:
ERR no package metadata for file file:///Users/wayneforrest/Documents/Projects/nextup/nextup-lib/main_windows.go: Error: no package metadata for file file:///Users/wayneforrest/Documents/Projects/nextup/nextup-lib/main_windows.go at handleResponse (/Users/wayneforrest/.vscode/extensions/golang.go-0.41.4/dist/goMain.js:8606:40) at handleMessage (/Users/wayneforrest/.vscode/extensions/golang.go-0.41.4/dist/goMain.js:8416:11) at processMessageQueue (/Users/wayneforrest/.vscode/extensions/golang.go-0.41.4/dist/goMain.js:8431:13) at Immediate.<anonymous> (/Users/wayneforrest/.vscode/extensions/golang.go-0.41.4/dist/goMain.js:8407:11) at process.processImmediate (node:internal/timers:476:21)

Note the stdlog:
import ( "fmt" stdLog "log" "runtime/debug" "sync" "time"

Screenshot 2024-05-25 at 2 12 16 PM

What did you expect to see?

When I navigate to the symbol/function from the main_darwin.go file, it works, but not when I navigate from main_windows.go file.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels May 25, 2024
@gopherbot gopherbot added this to the Unreleased milestone May 25, 2024
@findleyr
Copy link
Contributor

Hi, which gopls version are you using? This should work from gopls@v0.15.0+.

@adonovan adonovan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls/metadata Issues related to metadata loading in gopls labels May 29, 2024
@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 30, 2024
@findleyr
Copy link
Contributor

In a dupe of this issue (golang/vscode-go#3421), we learned that this is related to cgo files, and the fact that cross platform development implies CGO_ENABLED=0.

Therefore, this is a dupe of #65758.

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/metadata Issues related to metadata loading in gopls gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants