go
                                
                                 go copied to clipboard
                                
                                    go copied to clipboard
                            
                            
                            
                        x/tools/gopls: package (still) not found when "linksInHover": "gopls"
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)
From the Source Action: (URL: http://127.0.0.1:63774/gopls/on0HKAhym30/pkg/github.com/google/flatbuffers/go?view=1#Builder
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
Related Issues
- x/tools/gopls: negated build flag causes error #59346
- x/tools/gopls: Implement action should ignore importing the current package #61830 (closed)
- x/tools/gopls: improve error message when using wrong go command with Go source distribution #35520
- x/tools/gopls: #52425 (closed)
- x/tools/gopls: not working #37119 (closed)
- x/tools/gopls: staticcheck QF1003 quickfix produces corrupted textedit #63930
- x/tools/gopls: cannot install gopls v0.6.8 #45099 (closed)
- x/tools/gopls: invalid build configuration with symlinked GOPATH #38558 (closed)
- x/tools/gopls: does not properly support go module on spacemac #33612 (closed)
- x/tools/gopls: undeclared name when accessing symbols from other files #35337 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
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?
Thanks, we'll take a look and fix for v0.16.1 if possible.
CC @adonovan
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.
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 Maybe you can help your fellow Googler's ;-) ? https://github.com/google/flatbuffers/pull/7783
@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.
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.