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: doesn't work well when jumping to definitions through the module cache #32209

Closed
stamblerre opened this issue May 23, 2019 · 22 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@stamblerre
Copy link
Contributor

Forked from upstream: microsoft/vscode-go#2533.

@gopherbot gopherbot added this to the Unreleased milestone May 23, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label May 23, 2019
@julieqiu julieqiu added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 28, 2019
@bmhatfield
Copy link

I've attempted to create a minimal reproduce case for this, and I cannot.

This works fine:

package main

import (
	"log"
	"google.golang.org/grpc"
)

func main() {
	_, err := grpc.Dial(":8080", grpc.WithInsecure())
	if err != nil {
		log.Println(err)
	}
}

Within VSCode, I can navigate by clicking through Dial and am able to jump to other functions/etc from there.

However, I have a much larger project - effectively a Go monorepo - and within that, the same code navigation does not work. Clicking dial brings me to GRPC, but I can't then navigate to anything else.

I've had coworkers report that gopls with vim works fine with our monorepo, so this may actually be a VSCode issue despite the fact that the issue was moved over here.

I am not really sure how to gather debug output/diagnostics, or what I would need to do to assemble a reproduce case for this given that a super minimal case doesn't result in any issues. If you've got suggestions, I am happy to follow them, however.

@stamblerre
Copy link
Contributor Author

You can share your VSCode gopls logs by going to "View: Debug Console" -> "Output" -> "Tasks" -> "gopls". Feel free to redact any private data, but that could at least show us what error messages you are getting.

@bmhatfield
Copy link

Thanks for that information! I was able to capture some logs:

[Error - 7:37:16 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/github.com/spf13/viper@v1.3.3-0.20190408140645-7a605a50e69c/viper.go: /Users/bhatfield/go/pkg/mod/github.com/spf13/viper@v1.3.3-0.20190408140645-7a605a50e69c/viper.go: no packages found
[Error - 7:37:16 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/github.com/spf13/viper@v1.3.3-0.20190408140645-7a605a50e69c/viper.go: /Users/bhatfield/go/pkg/mod/github.com/spf13/viper@v1.3.3-0.20190408140645-7a605a50e69c/viper.go: no packages found
[Error - 7:37:16 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/github.com/spf13/viper@v1.3.3-0.20190408140645-7a605a50e69c/viper.go: /Users/bhatfield/go/pkg/mod/github.com/spf13/viper@v1.3.3-0.20190408140645-7a605a50e69c/viper.go: no packages found
[Error - 7:37:16 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:16 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:16 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:17 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:17 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:17 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:17 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:17 PM] Request textDocument/documentLink failed.
  Message: no AST for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:17 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:17 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:17 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:17 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:17 PM] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:17 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:18 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:18 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:18 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:18 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:18 PM] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:18 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:18 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:18 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:18 PM] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:22 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:23 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:23 PM] Request textDocument/definition failed.
  Message: no AST for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:23 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:23 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:23 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:23 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:23 PM] Request textDocument/definition failed.
  Message: no AST for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:23 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:23 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:23 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:23 PM] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:24 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:24 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:24 PM] Request textDocument/hover failed.
  Message: no AST for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:25 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:25 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:25 PM] Request textDocument/hover failed.
  Message: no AST for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:25 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:25 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:25 PM] Request textDocument/definition failed.
  Message: no AST for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:25 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:25 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:25 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:25 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:25 PM] Request textDocument/definition failed.
  Message: no AST for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 
[Error - 7:37:25 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:26 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:26 PM] unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
[Error - 7:37:26 PM] Request textDocument/codeAction failed.
  Message: no file information for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
  Code: 0 

clientconn.go was the file I had jumped to (via Dial) and was attempting to navigate from.

It starts off like this:

[bhatfield go-services]% head /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
/*
 *
 * Copyright 2014 gRPC authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *

@bmhatfield
Copy link

Happy to gather further information as needed.

@bmhatfield
Copy link

Also, confirmed that both my minimal repro attempt (which works fine) and the larger monorepo (which does not) both use the same grpc and have the same sum:

google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0=

@ianthehat
Copy link

can you try
gopls check /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go

also if you do
gopackages file=/Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
from within the monorepo what do you get?

If you don't have that binary you can get it with
go get -u golang.org/x/tools/go/packages/gopackages

@bmhatfield
Copy link

bmhatfield commented May 31, 2019

% gopls check /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
2019/05/30 21:22:33 Error:unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
2019/05/30 21:22:33 Error:unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
2019/05/30 21:22:33 Error:unable to check package for file:///Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
/Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go: no packages found
% gopackages file=/Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
Go package "google.golang.org/grpc":
	package grpc
	has no exported type info
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/backoff.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/balancer.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/balancer_conn_wrappers.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/balancer_v1_wrapper.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/call.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/codec.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/dialoptions.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/doc.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/interceptor.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/picker_wrapper.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/pickfirst.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/preloader.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/proxy.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/resolver_conn_wrapper.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/rpc_util.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/server.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/service_config.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/stream.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/trace.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/version.go
	import "bufio"
	import "bytes"
	import "compress/gzip"
	import "context"
	import "encoding/base64"
	import "encoding/binary"
	import "encoding/json"
	import "errors"
	import "fmt"
	import "golang.org/x/net/trace"
	import "google.golang.org/grpc/balancer"
	import "google.golang.org/grpc/balancer/roundrobin"
	import "google.golang.org/grpc/codes"
	import "google.golang.org/grpc/connectivity"
	import "google.golang.org/grpc/credentials"
	import "google.golang.org/grpc/encoding"
	import "google.golang.org/grpc/encoding/proto"
	import "google.golang.org/grpc/grpclog"
	import "google.golang.org/grpc/internal"
	import "google.golang.org/grpc/internal/backoff"
	import "google.golang.org/grpc/internal/balancerload"
	import "google.golang.org/grpc/internal/binarylog"
	import "google.golang.org/grpc/internal/channelz"
	import "google.golang.org/grpc/internal/envconfig"
	import "google.golang.org/grpc/internal/grpcrand"
	import "google.golang.org/grpc/internal/grpcsync"
	import "google.golang.org/grpc/internal/transport"
	import "google.golang.org/grpc/keepalive"
	import "google.golang.org/grpc/metadata"
	import "google.golang.org/grpc/naming"
	import "google.golang.org/grpc/peer"
	import "google.golang.org/grpc/resolver"
	import "google.golang.org/grpc/resolver/dns"
	import "google.golang.org/grpc/resolver/passthrough"
	import "google.golang.org/grpc/stats"
	import "google.golang.org/grpc/status"
	import "google.golang.org/grpc/tap"
	import "io"
	import "io/ioutil"
	import "math"
	import "net"
	import "net/http"
	import "net/http/httputil"
	import "net/url"
	import "reflect"
	import "runtime"
	import "strconv"
	import "strings"
	import "sync"
	import "sync/atomic"
	import "time"

(edit: I initially ran gopackages from the wrong place. Updated)

@bmhatfield
Copy link

Just did a little spelunking with gopackages and it appears we're hitting this block: https://github.com/golang/tools/blob/master/go/packages/packages.go#L621-L625 which is why it reports that there's no exported types.

@stamblerre
Copy link
Contributor Author

@bmhatfield: What do you mean by that? Is there a bug in the gopackages command?

@bmhatfield
Copy link

I'm not sure - I tried to do a little spelunking to see if I could provide some additional context, but I got a bit turned around with gopackages' code and thought it was a weird block to be hitting, but I really don't know how this tool is intended to work.

@freeformz
Copy link

@bmhatfield Run the following:
gopackages -mode types file=/Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go and you should get exported type info.

gopackage's mode flag accepts the following values: files, imports, types, syntax, allsyntax
It defaults to "imports" and each progression to the right increases the analysis / verbosity.

@bmhatfield
Copy link

Thanks for the tip!

Running this gets me type information as you indicated. However first run is very slow (I assume compiling).

Go package "google.golang.org/grpc":
	package grpc
	has complete exported type info
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/backoff.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/balancer.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/balancer_conn_wrappers.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/balancer_v1_wrapper.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/call.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/clientconn.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/codec.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/dialoptions.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/doc.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/interceptor.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/picker_wrapper.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/pickfirst.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/preloader.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/proxy.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/resolver_conn_wrapper.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/rpc_util.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/server.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/service_config.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/stream.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/trace.go
	file /Users/bhatfield/go/pkg/mod/google.golang.org/grpc@v1.21.0/version.go
	import "bufio"
	import "bytes"
	import "compress/gzip"
	import "context"
	import "encoding/base64"
	import "encoding/binary"
	import "encoding/json"
	import "errors"
	import "fmt"
	import "golang.org/x/net/trace"
	import "google.golang.org/grpc/balancer"
	import "google.golang.org/grpc/balancer/roundrobin"
	import "google.golang.org/grpc/codes"
	import "google.golang.org/grpc/connectivity"
	import "google.golang.org/grpc/credentials"
	import "google.golang.org/grpc/encoding"
	import "google.golang.org/grpc/encoding/proto"
	import "google.golang.org/grpc/grpclog"
	import "google.golang.org/grpc/internal"
	import "google.golang.org/grpc/internal/backoff"
	import "google.golang.org/grpc/internal/balancerload"
	import "google.golang.org/grpc/internal/binarylog"
	import "google.golang.org/grpc/internal/channelz"
	import "google.golang.org/grpc/internal/envconfig"
	import "google.golang.org/grpc/internal/grpcrand"
	import "google.golang.org/grpc/internal/grpcsync"
	import "google.golang.org/grpc/internal/transport"
	import "google.golang.org/grpc/keepalive"
	import "google.golang.org/grpc/metadata"
	import "google.golang.org/grpc/naming"
	import "google.golang.org/grpc/peer"
	import "google.golang.org/grpc/resolver"
	import "google.golang.org/grpc/resolver/dns"
	import "google.golang.org/grpc/resolver/passthrough"
	import "google.golang.org/grpc/stats"
	import "google.golang.org/grpc/status"
	import "google.golang.org/grpc/tap"
	import "io"
	import "io/ioutil"
	import "math"
	import "net"
	import "net/http"
	import "net/http/httputil"
	import "net/url"
	import "reflect"
	import "runtime"
	import "strconv"
	import "strings"
	import "sync"
	import "sync/atomic"
	import "time"
	type Address struct{Addr string; Metadata interface{}}
	type BackoffConfig struct{MaxDelay time.Duration}
	type Balancer interface{Close() error; Get(ctx context.Context, opts BalancerGetOptions) (addr Address, put func(), err error); Notify() <-chan []Address; Start(target string, config BalancerConfig) error; Up(addr Address) (down func(error))}
	method (Balancer) Close() error
	method (Balancer) Get(ctx context.Context, opts BalancerGetOptions) (addr Address, put func(), err error)
	method (Balancer) Notify() <-chan []Address
	method (Balancer) Start(target string, config BalancerConfig) error
	method (Balancer) Up(addr Address) (down func(error))
	type BalancerConfig struct{DialCreds google.golang.org/grpc/credentials.TransportCredentials; Dialer func(context.Context, string) (net.Conn, error)}
	type BalancerGetOptions struct{BlockingWait bool}
	func CallContentSubtype(contentSubtype string) CallOption
	func CallCustomCodec(codec Codec) CallOption
	type CallOption interface{after(*callInfo); before(*callInfo) error}
	type ClientConn struct{ctx context.Context; cancel context.CancelFunc; target string; parsedTarget google.golang.org/grpc/resolver.Target; authority string; dopts dialOptions; csMgr *connectivityStateManager; balancerBuildOpts google.golang.org/grpc/balancer.BuildOptions; blockingpicker *pickerWrapper; mu sync.RWMutex; resolverWrapper *ccResolverWrapper; sc *ServiceConfig; conns map[*addrConn]struct{}; mkp google.golang.org/grpc/keepalive.ClientParameters; curBalancerName string; balancerWrapper *ccBalancerWrapper; retryThrottler sync/atomic.Value; firstResolveEvent *google.golang.org/grpc/internal/grpcsync.Event; channelzID int64; czData *channelzData}
	method (*ClientConn) Close() error
	method (*ClientConn) GetMethodConfig(method string) MethodConfig
	method (*ClientConn) GetState() google.golang.org/grpc/connectivity.State
	method (*ClientConn) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...CallOption) error
	method (*ClientConn) NewStream(ctx context.Context, desc *StreamDesc, method string, opts ...CallOption) (ClientStream, error)
	method (*ClientConn) ResetConnectBackoff()
	method (*ClientConn) Target() string
	method (*ClientConn) WaitForStateChange(ctx context.Context, sourceState google.golang.org/grpc/connectivity.State) bool
	type ClientStream interface{CloseSend() error; Context() context.Context; Header() (google.golang.org/grpc/metadata.MD, error); RecvMsg(m interface{}) error; SendMsg(m interface{}) error; Trailer() google.golang.org/grpc/metadata.MD}
	method (ClientStream) CloseSend() error
	method (ClientStream) Context() context.Context
	method (ClientStream) Header() (google.golang.org/grpc/metadata.MD, error)
	method (ClientStream) RecvMsg(m interface{}) error
	method (ClientStream) SendMsg(m interface{}) error
	method (ClientStream) Trailer() google.golang.org/grpc/metadata.MD
	func Code(err error) google.golang.org/grpc/codes.Code
	type Codec interface{Marshal(v interface{}) ([]byte, error); String() string; Unmarshal(data []byte, v interface{}) error}
	method (Codec) Marshal(v interface{}) ([]byte, error)
	method (Codec) String() string
	method (Codec) Unmarshal(data []byte, v interface{}) error
	type Compressor interface{Do(w io.Writer, p []byte) error; Type() string}
	method (Compressor) Do(w io.Writer, p []byte) error
	method (Compressor) Type() string
	type CompressorCallOption struct{CompressorType string}
	func ConnectionTimeout(d time.Duration) ServerOption
	type ContentSubtypeCallOption struct{ContentSubtype string}
	func Creds(c google.golang.org/grpc/credentials.TransportCredentials) ServerOption
	func CustomCodec(codec Codec) ServerOption
	type CustomCodecCallOption struct{Codec Codec}
	type Decompressor interface{Do(r io.Reader) ([]byte, error); Type() string}
	method (Decompressor) Do(r io.Reader) ([]byte, error)
	method (Decompressor) Type() string
	var DefaultBackoffConfig BackoffConfig
	func Dial(target string, opts ...DialOption) (*ClientConn, error)
	func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *ClientConn, err error)
	type DialOption interface{apply(*dialOptions)}
	type EmptyCallOption struct{}
	type EmptyDialOption struct{}
	type EmptyServerOption struct{}
	var EnableTracing bool
	var ErrClientConnClosing error
	var ErrClientConnTimeout error
	var ErrServerStopped error
	func ErrorDesc(err error) string
	func Errorf(c google.golang.org/grpc/codes.Code, format string, a ...interface{}) error
	func FailFast(failFast bool) CallOption
	type FailFastCallOption struct{FailFast bool}
	func FailOnNonTempDialError(f bool) DialOption
	func ForceCodec(codec google.golang.org/grpc/encoding.Codec) CallOption
	type ForceCodecCallOption struct{Codec google.golang.org/grpc/encoding.Codec}
	func Header(md *google.golang.org/grpc/metadata.MD) CallOption
	type HeaderCallOption struct{HeaderAddr *google.golang.org/grpc/metadata.MD}
	func InTapHandle(h google.golang.org/grpc/tap.ServerInHandle) ServerOption
	func InitialConnWindowSize(s int32) ServerOption
	func InitialWindowSize(s int32) ServerOption
	func Invoke(ctx context.Context, method string, args interface{}, reply interface{}, cc *ClientConn, opts ...CallOption) error
	func KeepaliveEnforcementPolicy(kep google.golang.org/grpc/keepalive.EnforcementPolicy) ServerOption
	func KeepaliveParams(kp google.golang.org/grpc/keepalive.ServerParameters) ServerOption
	func MaxCallRecvMsgSize(s int) CallOption
	func MaxCallSendMsgSize(s int) CallOption
	func MaxConcurrentStreams(n uint32) ServerOption
	func MaxHeaderListSize(s uint32) ServerOption
	func MaxMsgSize(m int) ServerOption
	func MaxRecvMsgSize(m int) ServerOption
	type MaxRecvMsgSizeCallOption struct{MaxRecvMsgSize int}
	func MaxRetryRPCBufferSize(bytes int) CallOption
	type MaxRetryRPCBufferSizeCallOption struct{MaxRetryRPCBufferSize int}
	func MaxSendMsgSize(m int) ServerOption
	type MaxSendMsgSizeCallOption struct{MaxSendMsgSize int}
	func Method(ctx context.Context) (string, bool)
	type MethodConfig struct{WaitForReady *bool; Timeout *time.Duration; MaxReqSize *int; MaxRespSize *int; retryPolicy *retryPolicy}
	type MethodDesc struct{MethodName string; Handler methodHandler}
	func MethodFromServerStream(stream ServerStream) (string, bool)
	type MethodInfo struct{Name string; IsClientStream bool; IsServerStream bool}
	func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error)
	func NewContextWithServerTransportStream(ctx context.Context, stream ServerTransportStream) context.Context
	func NewGZIPCompressor() Compressor
	func NewGZIPCompressorWithLevel(level int) (Compressor, error)
	func NewGZIPDecompressor() Decompressor
	func NewServer(opt ...ServerOption) *Server
	func Peer(p *google.golang.org/grpc/peer.Peer) CallOption
	type PeerCallOption struct{PeerAddr *google.golang.org/grpc/peer.Peer}
	func PerRPCCredentials(creds google.golang.org/grpc/credentials.PerRPCCredentials) CallOption
	type PerRPCCredsCallOption struct{Creds google.golang.org/grpc/credentials.PerRPCCredentials}
	const PickFirstBalancerName untyped string
	type PreparedMsg struct{encodedData []byte; hdr []byte; payload []byte}
	method (*PreparedMsg) Encode(s Stream, msg interface{}) error
	func RPCCompressor(cp Compressor) ServerOption
	func RPCDecompressor(dc Decompressor) ServerOption
	func ReadBufferSize(s int) ServerOption
	func RoundRobin(r google.golang.org/grpc/naming.Resolver) Balancer
	func SendHeader(ctx context.Context, md google.golang.org/grpc/metadata.MD) error
	type Server struct{opts serverOptions; mu sync.Mutex; lis map[net.Listener]bool; conns map[io.Closer]bool; serve bool; drain bool; cv *sync.Cond; m map[string]*service; events golang.org/x/net/trace.EventLog; quit chan struct{}; done chan struct{}; quitOnce sync.Once; doneOnce sync.Once; channelzRemoveOnce sync.Once; serveWG sync.WaitGroup; channelzID int64; czData *channelzData}
	method (*Server) GetServiceInfo() map[string]ServiceInfo
	method (*Server) GracefulStop()
	method (*Server) RegisterService(sd *ServiceDesc, ss interface{})
	method (*Server) Serve(lis net.Listener) error
	method (*Server) ServeHTTP(w net/http.ResponseWriter, r *net/http.Request)
	method (*Server) Stop()
	type ServerOption interface{apply(*serverOptions)}
	type ServerStream interface{Context() context.Context; RecvMsg(m interface{}) error; SendHeader(google.golang.org/grpc/metadata.MD) error; SendMsg(m interface{}) error; SetHeader(google.golang.org/grpc/metadata.MD) error; SetTrailer(google.golang.org/grpc/metadata.MD)}
	method (ServerStream) Context() context.Context
	method (ServerStream) RecvMsg(m interface{}) error
	method (ServerStream) SendHeader(google.golang.org/grpc/metadata.MD) error
	method (ServerStream) SendMsg(m interface{}) error
	method (ServerStream) SetHeader(google.golang.org/grpc/metadata.MD) error
	method (ServerStream) SetTrailer(google.golang.org/grpc/metadata.MD)
	type ServerTransportStream interface{Method() string; SendHeader(md google.golang.org/grpc/metadata.MD) error; SetHeader(md google.golang.org/grpc/metadata.MD) error; SetTrailer(md google.golang.org/grpc/metadata.MD) error}
	method (ServerTransportStream) Method() string
	method (ServerTransportStream) SendHeader(md google.golang.org/grpc/metadata.MD) error
	method (ServerTransportStream) SetHeader(md google.golang.org/grpc/metadata.MD) error
	method (ServerTransportStream) SetTrailer(md google.golang.org/grpc/metadata.MD) error
	func ServerTransportStreamFromContext(ctx context.Context) ServerTransportStream
	type ServiceConfig struct{LB *string; Methods map[string]MethodConfig; retryThrottling *retryThrottlingPolicy; healthCheckConfig *healthCheckConfig; rawJSONString string}
	type ServiceDesc struct{ServiceName string; HandlerType interface{}; Methods []MethodDesc; Streams []StreamDesc; Metadata interface{}}
	type ServiceInfo struct{Methods []MethodInfo; Metadata interface{}}
	func SetHeader(ctx context.Context, md google.golang.org/grpc/metadata.MD) error
	func SetTrailer(ctx context.Context, md google.golang.org/grpc/metadata.MD) error
	func StatsHandler(h google.golang.org/grpc/stats.Handler) ServerOption
	type Stream interface{Context() context.Context; RecvMsg(m interface{}) error; SendMsg(m interface{}) error}
	method (Stream) Context() context.Context
	method (Stream) RecvMsg(m interface{}) error
	method (Stream) SendMsg(m interface{}) error
	type StreamClientInterceptor func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, streamer Streamer, opts ...CallOption) (ClientStream, error)
	type StreamDesc struct{StreamName string; Handler StreamHandler; ServerStreams bool; ClientStreams bool}
	type StreamHandler func(srv interface{}, stream ServerStream) error
	func StreamInterceptor(i StreamServerInterceptor) ServerOption
	type StreamServerInfo struct{FullMethod string; IsClientStream bool; IsServerStream bool}
	type StreamServerInterceptor func(srv interface{}, ss ServerStream, info *StreamServerInfo, handler StreamHandler) error
	type Streamer func(ctx context.Context, desc *StreamDesc, cc *ClientConn, method string, opts ...CallOption) (ClientStream, error)
	const SupportPackageIsVersion3 untyped bool
	const SupportPackageIsVersion4 untyped bool
	const SupportPackageIsVersion5 untyped bool
	func Trailer(md *google.golang.org/grpc/metadata.MD) CallOption
	type TrailerCallOption struct{TrailerAddr *google.golang.org/grpc/metadata.MD}
	type UnaryClientInterceptor func(ctx context.Context, method string, req interface{}, reply interface{}, cc *ClientConn, invoker UnaryInvoker, opts ...CallOption) error
	type UnaryHandler func(ctx context.Context, req interface{}) (interface{}, error)
	func UnaryInterceptor(i UnaryServerInterceptor) ServerOption
	type UnaryInvoker func(ctx context.Context, method string, req interface{}, reply interface{}, cc *ClientConn, opts ...CallOption) error
	type UnaryServerInfo struct{Server interface{}; FullMethod string}
	type UnaryServerInterceptor func(ctx context.Context, req interface{}, info *UnaryServerInfo, handler UnaryHandler) (resp interface{}, err error)
	func UnknownServiceHandler(streamHandler StreamHandler) ServerOption
	func UseCompressor(name string) CallOption
	const Version untyped string
	func WaitForReady(waitForReady bool) CallOption
	func WithAuthority(a string) DialOption
	func WithBackoffConfig(b BackoffConfig) DialOption
	func WithBackoffMaxDelay(md time.Duration) DialOption
	func WithBalancer(b Balancer) DialOption
	func WithBalancerName(balancerName string) DialOption
	func WithBlock() DialOption
	func WithChainStreamInterceptor(interceptors ...StreamClientInterceptor) DialOption
	func WithChainUnaryInterceptor(interceptors ...UnaryClientInterceptor) DialOption
	func WithChannelzParentID(id int64) DialOption
	func WithCodec(c Codec) DialOption
	func WithCompressor(cp Compressor) DialOption
	func WithContextDialer(f func(context.Context, string) (net.Conn, error)) DialOption
	func WithCredentialsBundle(b google.golang.org/grpc/credentials.Bundle) DialOption
	func WithDecompressor(dc Decompressor) DialOption
	func WithDefaultCallOptions(cos ...CallOption) DialOption
	func WithDefaultServiceConfig(s string) DialOption
	func WithDialer(f func(string, time.Duration) (net.Conn, error)) DialOption
	func WithDisableHealthCheck() DialOption
	func WithDisableRetry() DialOption
	func WithDisableServiceConfig() DialOption
	func WithInitialConnWindowSize(s int32) DialOption
	func WithInitialWindowSize(s int32) DialOption
	func WithInsecure() DialOption
	func WithKeepaliveParams(kp google.golang.org/grpc/keepalive.ClientParameters) DialOption
	func WithMaxHeaderListSize(s uint32) DialOption
	func WithMaxMsgSize(s int) DialOption
	func WithPerRPCCredentials(creds google.golang.org/grpc/credentials.PerRPCCredentials) DialOption
	func WithReadBufferSize(s int) DialOption
	func WithServiceConfig(c <-chan ServiceConfig) DialOption
	func WithStatsHandler(h google.golang.org/grpc/stats.Handler) DialOption
	func WithStreamInterceptor(f StreamClientInterceptor) DialOption
	func WithTimeout(d time.Duration) DialOption
	func WithTransportCredentials(creds google.golang.org/grpc/credentials.TransportCredentials) DialOption
	func WithUnaryInterceptor(f UnaryClientInterceptor) DialOption
	func WithUserAgent(s string) DialOption
	func WithWaitForHandshake() DialOption
	func WithWriteBufferSize(s int) DialOption
	func WriteBufferSize(s int) ServerOption

@bmhatfield
Copy link

What else can I do to help gather information here?

@marco-m
Copy link

marco-m commented Jun 12, 2019

@julieqiu who could perform the investigation as per the NeedsInvestigation label? If this can help, as vscode user I see the same problem.

@thepudds
Copy link
Contributor

@marco-m Would you be able to supply the logs and other diagnostic information suggested in the troubleshooting section here:

https://github.com/golang/go/wiki/gopls

@marco-m
Copy link

marco-m commented Jun 13, 2019

@thepudds I wanted to provide the diagnostics, but now I cannot reproduce the problem any more 🤔so I am happy and confused :-)
macOS 10.14.5
vscode 1.35.1 (updated today)
go 1.12.6 (updated today)
gopls fetched by vscode today after update to go 1.12.6, version "v0.1.0-cmd.gopls, built in $GOPATH mode"

@stamblerre
Copy link
Contributor Author

@bmhatfield: Are you still seeing this issue with the latest version of gopls (run go get -u golang.org/x/tools/cmd/gopls to update)?

@cocodee
Copy link

cocodee commented Jun 19, 2019

It seems that the issue still exists in the latest code?

@stamblerre
Copy link
Contributor Author

@cocodee: Can you provide logs like the ones above for the case you are seeing?

@bmhatfield
Copy link

@stamblerre it appears that this issue is improved! But unfortunately not fully resolved.

Jumping through .Dial() now allows me to continue on my journey for some things in that package, but there's a number of things that are now underlined/highlighted as undefined symbols (but are most definitely not undefined).

Screen Shot 2019-06-24 at 7 30 10 AM

@stamblerre
Copy link
Contributor Author

Do the red underlines also appear when you do jump to definition from the minimal case? (the one from earlier that did work for you). Do you see any new error messages in the gopls logs?

@stamblerre stamblerre changed the title x/tools/cmd/gopls: doesn't work well when jumping to definitions through the module cache x/tools/gopls: doesn't work well when jumping to definitions through the module cache Jul 2, 2019
@stamblerre stamblerre added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 5, 2019
@stamblerre
Copy link
Contributor Author

Going to close this issue since it's been about a month since the last discussion. Please open a new issue if this problem persists.

@golang golang locked and limited conversation to collaborators Aug 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

9 participants