Skip to content

References CodeLens is not working #1643

@robsonpeixoto

Description

@robsonpeixoto

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions