Skip to content

x/tools/gopls: compute analysis facts for non-workspace packages #48738

@goblinfactory

Description

@goblinfactory

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

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go1.17 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.7.2
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.60.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.28.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • gopkgs: /Users/{username}/go/bin/gopkgs: go1.17
    • go-outline: /Users/{username}/go/bin/go-outline: go1.17
    • gotests: /Users/{username}/go/bin/gotests: go1.17
    • gomodifytags: /Users/{username}/go/bin/gomodifytags: go1.17
    • impl: /Users/{username}/go/bin/impl: go1.17
    • goplay: /Users/{username}/go/bin/goplay: go1.17
    • dlv: /Users/{username}/go/bin/dlv: go1.17
    • dlv-dap: /Users/{username}/go/bin/dlv-dap: go1.17
    • golint: /Users/{username}/go/bin/golint: go1.17
    • gopls: /Users/{username}/go/bin/gopls: go1.17

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

{
    "go.toolsManagement.autoUpdate": true,
    "go.lintTool": "golint",
    "go.vetOnSave": "workspace"
}

Describe the bug

When "Go:vet On Save is enabled in settings; and a go file is edited and saved (containing an error that go vet ./... does pick up), then no error squiggles appear in the editor to show that there is a vet error.

Required behavior

When "Go:vet On Save is enabled in settings; and a go file is edited and saved (containing an error that go vet ./... does pick up), then error squiggles MUST appear in the editor to show that there is a vet error.

Steps to reproduce the behavior:

  1. given a go file testvet.go with the following code
package testvet

import (
	"fmt"
	"sync"
)

// TestThatVetRunsOnSave minimal code to show vet not running on save in VS code
func TestThatVetRunsOnSave() {

	ch := make(chan string)
	var wg sync.WaitGroup
	wg.Add(1)
	go printit(wg, ch)

	ch <- "one"
	ch <- "two"
	close(ch)
	wg.Wait()
	fmt.Println("done.")

}

func printit(wg sync.WaitGroup, ch chan string) {
	defer wg.Done()
	for t := range ch {
		fmt.Println(t)
	}
}
  1. When I edit any text in this file that changes something, for example a space or comment
  2. Then the editor should highlight the same lines of code containing vet errors, that the command line go vet ./... picks up as having an error.
pkg/testvet/testvet.go:14:13: call of printit copies lock value: sync.WaitGroup contains sync.noCopy
pkg/testvet/testvet.go:24:17: printit passes lock by value: sync.WaitGroup contains sync.noCopy
  1. Manually running the command , Go:vet workspace does work and causes the editor to report the correct errors and squigglies. (see screenshot below)

Screenshots or recordings

To be clear, the screenshot below is the behaviour that we WANT to happen and be triggered on save, this is currently not happening and only happens when you manually run the command Go;vet workspace

Screenshot 2021-10-01 at 19 33 36

In addition to this functionality not working, the user interface helptext in VSCode settings does not make sense. The setting helptext has this text, which refers to functionality that I believe is not longer valid.

Screenshot 2021-10-01 at 19 45 06

I have tried all variations of this setting value; both package and workspace. Neither works.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/analysisIssues related to running analysis in goplsgopls/performanceIssues related to gopls performance (CPU, memory, etc).

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions