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

References CodeLens is not working #1643

Closed
robsonpeixoto opened this issue Jul 22, 2021 · 2 comments
Closed

References CodeLens is not working #1643

robsonpeixoto opened this issue Jul 22, 2021 · 2 comments

Comments

@robsonpeixoto
Copy link

robsonpeixoto commented Jul 22, 2021

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go from the VS Code integrated terminal.
% go version 
go version go1.16.6 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
% gopls -v version
Build info
----------
golang.org/x/tools/gopls v0.7.0
    golang.org/x/tools/[email protected] h1:JQBHW81Gsyim6iDjUwGoPeSpXrSqwen3isPJLfDfaYU=
    github.com/BurntSushi/[email protected] h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/[email protected] h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
    github.com/sergi/[email protected] h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/[email protected] h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
    golang.org/x/[email protected] h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
    golang.org/x/[email protected] h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
    golang.org/x/[email protected] h1:Pv9gNyJFYVdpUAVZYJ1BDSU4eGgXQ+0f3DIGAdolO5s=
    golang.org/x/[email protected] h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/[email protected] h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
    mvdan.cc/[email protected] h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
    mvdan.cc/xurls/[email protected] h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
% code -v
1.58.2
c3f126316369cd610563c75b1b1725e0679adfb3
x64
  • Check your installed extensions to get the version of the VS Code Go extension
    `0.26.0

  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

Checking configured tools....
GOBIN: undefined
toolsGopath: 
gopath: /Users/robinho/go
GOROOT: /usr/local/Cellar/go/1.16.6/libexec
PATH: /Users/robinho/.asdf/shims:/usr/local/opt/asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS:/Users/robinho/.npm-global/bin:/Users/robinho/.local/bin:/usr/local/sbin:/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin:/Users/robinho/.mix/escripts:/Users/robinho/go/bin

   gopkgs: /Users/robinho/go/bin/gopkgs installed
   go-outline: /Users/robinho/go/bin/go-outline installed
   gotests: /Users/robinho/go/bin/gotests installed
   gomodifytags: /Users/robinho/go/bin/gomodifytags installed
   impl: /Users/robinho/go/bin/impl installed
   goplay: /Users/robinho/go/bin/goplay installed
   dlv: /Users/robinho/go/bin/dlv installed
   dlv-dap: /Users/robinho/go/bin/dlv-dap installed
   golangci-lint: /Users/robinho/go/bin/golangci-lint installed
   gopls: /Users/robinho/go/bin/gopls installed

go env
Workspace Folder (oxe): /Users/robinho/tmp/oxe
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/Users/robinho/Library/Caches/go-build"
	GOENV="/Users/robinho/Library/Application Support/go/env"
	GOEXE=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="darwin"
	GOINSECURE=""
	GOMODCACHE="/Users/robinho/go/pkg/mod"
	GONOPROXY="github.com/MyPrivateOrg/*"
	GONOSUMDB="github.com/MyPrivateOrg/*"
	GOOS="darwin"
	GOPATH="/Users/robinho/go"
	GOPRIVATE="github.com/MyPrivateOrg/*"
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/usr/local/Cellar/go/1.16.6/libexec"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/usr/local/Cellar/go/1.16.6/libexec/pkg/tool/darwin_amd64"
	GOVCS=""
	GOVERSION="go1.16.6"
	GCCGO="gccgo"
	AR="ar"
	CC="clang"
	CXX="clang++"
	CGO_ENABLED="1"
	GOMOD="/Users/robinho/tmp/oxe/go.mod"
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/3r/qbz_rffn03l8r6p0skz5x60c0000gn/T/go-build1965722123=/tmp/go-build -gno-record-gcc-switches -fno-common"
	

Share the Go related settings you have added/edited

  "go.enableCodeLens": {
    "references": true,
    "runtest": true,
  },
  "[go]": {
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "file",
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    },
  },
  "[go.mod]": {
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "file",
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    }
  },
  "go.toolsEnvVars": {
    "GOPRIVATE": "github.com/MyPrivateOrg/*"
  },
  "go.delveConfig": {
    "debugAdapter": "dlv-dap",
  },
  "go.coverageDecorator": {
    "type": "gutter",
    "coveredHighlightColor": "rgba(64,128,128,0.5)",
    "uncoveredHighlightColor": "rgba(128,64,64,0.25)",
    "coveredGutterStyle": "blockgreen",
    "uncoveredGutterStyle": "blockred"
  },
  "go.coverShowCounts": true,
  "go.coverOnSave": false,
  "go.coverOnTestPackage": true,
  "go.coverOnSingleTestFile": true,
  "go.coverOnSingleTest": true,
  "go.toolsManagement.autoUpdate": true,
  "go.lintTool":"golangci-lint",
  "go.lintFlags": ["--fast"],
  "go.testFlags": ["-v"],
  "gopls": {
    // Add parameter placeholders when completing a function.
    "usePlaceholders": true,
    "analyses": {
      "ST1000": false, // at least one file in a package should have a package comment
    },
    "staticcheck": true,
    "formatting.gofumpt": true
  },

Describe the bug

CodeLens.references is disable by default, but it has a very useful information. I enabled it using the config below:

  "go.enableCodeLens": {
    "references": true,
    "runtest": true,
  },

The first off thing was that guru do not show on Go: Install/Update Tools and I needed to install using go get -u golang.org/x/tools/cmd/guru.

All interface reference count is 0 references.

Steps to reproduce the behavior:

This simple code:

package main

import "fmt"

type SayHi interface {
	Hi() string
}

type HiMan struct{}

func (HiMan) Hi() string {
	return "Hi Man"
}

func main() {
	sayHi(HiMan{})
}

func sayHi(s SayHi) {
	fmt.Println(s.Hi())
}

Screenshots or recordings

image

@gopherbot gopherbot added this to the Untriaged milestone Jul 22, 2021
@robsonpeixoto robsonpeixoto changed the title go.enableCodeLens references CodeLens is not working Jul 22, 2021
@suzmue
Copy link
Contributor

suzmue commented Jul 22, 2021

The first off thing was that guru do not show on Go: Install/Update Tools and I needed to install using go get -u golang.org/x/tools/cmd/guru.

With the language server enabled, the extension does not include guru as one of the tools. Since this feature is not implemented in gopls (see: golang/go#40862), perhaps we should consider including it in the list of tools even when the language server is enabled.

We are no longer maintaining guru in favor of gopls. If you would like to see support for this feature from gopls, please add your support to golang/go#40862.

@suzmue suzmue modified the milestones: Untriaged, Backlog Jul 22, 2021
@hyangah hyangah changed the title CodeLens is not working References CodeLens is not working Jul 23, 2021
@hyangah
Copy link
Contributor

hyangah commented Jul 23, 2021

The feature relies on guru and unfortunately, guru is no longer maintained and won't work well in Go module mode (which is the default in the latest Go version) even when we let guru handle this when the language server is enabled. Let's close this issue in favor of golang/go#40862.

@hyangah hyangah closed this as completed Jul 23, 2021
@golang golang locked and limited conversation to collaborators Sep 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants