go icon indicating copy to clipboard operation
go copied to clipboard

x/tools/gopls: package (still) not found when "linksInHover": "gopls"

Open freeformz opened this issue 1 year ago • 7 comments

gopls version

dev version installed from https://github.com/golang/tools/commit/8fa4173de3eb0507050500109922ff5012c5d635

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/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='go1.21.9'
GOTOOLDIR='/Users/emuller/go/pkg/mod/golang.org/[email protected]/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 https://github.com/golang/go/issues/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 avatar Jun 27 '24 16:06 freeformz

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

freeformz avatar Jun 27 '24 16:06 freeformz

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

CC @adonovan

findleyr avatar Jun 27 '24 17:06 findleyr

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.

findleyr avatar Jun 28 '24 20:06 findleyr

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",

adonovan avatar Jun 28 '24 20:06 adonovan

@adonovan Maybe you can help your fellow Googler's ;-) ? https://github.com/google/flatbuffers/pull/7783

freeformz avatar Jun 28 '24 23:06 freeformz

@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.

freeformz avatar Jun 28 '24 23:06 freeformz

Closing as a dup of https://github.com/golang/go/issues/68116, since fixed. Please reopen if you observe this again with the latest code.

adonovan avatar Jan 13 '25 20:01 adonovan