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: package (still) not found when "linksInHover": "gopls" #68223

Open
freeformz opened this issue Jun 27, 2024 · 7 comments
Open
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@freeformz
Copy link

freeformz commented Jun 27, 2024

gopls version

dev version installed from golang/tools@8fa4173

go env

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/emuller/Library/Caches/go-build'
GOENV='/Users/emuller/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/emuller/go/pkg/mod'
GONOPROXY='github.com/fastly,github.com/signalsciences'
GONOSUMDB='github.com/fastly,github.com/signalsciences'
GOOS='darwin'
GOPATH='/Users/emuller/go'
GOPRIVATE='github.com/fastly,github.com/signalsciences'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/emuller/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.9.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='go1.21.9'
GOTOOLDIR='/Users/emuller/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.21.9.darwin-arm64/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.9'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/emuller/go/src/github.com/signalsciences/sigsci/go.mod'
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/_r/zq_pfc8j04v_ppylrbg6mln80000gn/T/go-build2280828047=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

I installed from master and am having a similar problem to #68116

From doc link in the hover popup: (URL: http://127.0.0.1:63774/gopls/on0HKAhym30/pkg/github.com/google/flatbuffers?view=1#Builder)

Screenshot 2024-06-27 at 9 31 29 AM

From the Source Action: (URL: http://127.0.0.1:63774/gopls/on0HKAhym30/pkg/github.com/google/flatbuffers/go?view=1#Builder
Screenshot 2024-06-27 at 9 33 06 AM

Note the difference in the URLS....

http://127.0.0.1:63774/gopls/on0HKAhym30/pkg/github.com/google/flatbuffers?view=1#Builder
http://127.0.0.1:63774/gopls/on0HKAhym30/pkg/github.com/google/flatbuffers/go?view=1#Builder

The first one doesn't work, the second one does.

What did you see happen?

open the docs when clicking on the doc link in the hover popup

What did you expect to see?

open the docs when clicking on the doc link in the hover popup

Editor and settings

vscode

Logs

No response

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

Note: The specific issue in #68116 is fixed. I can now get to the grpc.DialContext w/o issue ... but something is still janky resolving the package name maybe?

@findleyr findleyr changed the title x/tools/gopls: issue title x/tools/gopls: package (still) not found when "linksInHover": "gopls" Jun 27, 2024
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.16.1 Jun 27, 2024
@findleyr
Copy link
Contributor

Thanks, we'll take a look and fix for v0.16.1 if possible.

CC @adonovan

@findleyr
Copy link
Contributor

I think @adonovan had not yet reproduced this. I'm sure there's a bug here, but it might not make v0.16.1, which we want to release early next week in light of the US holidays.

@adonovan
Copy link
Member

Indeed, I couldn't reproduce it. I notice that (a) there's no go.mod file and (b) the import path reported by go list is strange (or perhaps normal for pre-module packages?). Gopls' Hover seems to work fine on the result though, at least when it was invoked within the flatbuffers/go package. (@freeformz Is that what you were doing, or were you using Hover on a symbol imported from flatbuffers from outside the package?)

go$ pwd
/Users/adonovan/w/flatbuffers/go
go$ GO111MODULE=off go list -json . | head 
{
	"Dir": "/Users/adonovan/w/flatbuffers/go",
	"ImportPath": "_/Users/adonovan/w/flatbuffers/go",
	"Name": "flatbuffers",
	"Doc": "Package flatbuffers provides facilities to read and write flatbuffers objects.",
	"Match": [
		"."
	],
	"Stale": true,
	"StaleReason": "build ID mismatch",

@freeformz
Copy link
Author

@adonovan Maybe you can help your fellow Googler's ;-) ? google/flatbuffers#7783

@freeformz
Copy link
Author

freeformz commented Jun 28, 2024

@adonovan To expand on what I did ...

import (
	flatbuffers "github.com/google/flatbuffers/go"
)
...
func FinishMeasureBuffer(builder *flatbuffers.Builder, offset flatbuffers.UOffsetT) {
	builder.Finish(offset)
}
...

Hover over *flatbuffers.Builder in the function declaration, scroll down in the popover to the flatbuffers.Builder in gopls doc viewer and click that link to : http://127.0.0.1:60961/gopls/6eXi_3Yn_Pg/pkg/github.com/google/flatbuffers?view=1#Builder

I get the 404 error

Alternatively .. in the same code at the same place, right click on *flatbuffers.Builder in the function declaration, choose Source Action... from the menu, then click on Browse documentation for type flatbuffers.Builder and I get directed to: http://127.0.0.1:60961/gopls/6eXi_3Yn_Pg/pkg/github.com/google/flatbuffers/go?view=1#Builder

Which works and renders the documentation.

So one code path figured out the correct url (source action), the other one (popover) doesn't.

@findleyr findleyr modified the milestones: gopls/v0.16.1, gopls/v0.17.0 Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants