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

go vet flag "-composite=false" is ignored by editor #217

Closed
avivdolev opened this issue Jun 12, 2020 · 7 comments
Closed

go vet flag "-composite=false" is ignored by editor #217

avivdolev opened this issue Jun 12, 2020 · 7 comments

Comments

@avivdolev
Copy link

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

  • Run go version to get version of Go
    go version go1.14.4 linux/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    1.46.0
    a5d1cc28bb5da32ec67e86cc50f84c67cc690321
    x64
  • Check your installed extensions to get the version of the VS Code Go extension
    0.14.4
  • Run go env to get the go development environment details
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/root/go/src/aviv/hello/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build321001936=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

{
    "go.useLanguageServer": true,
    "go.vetFlags": [
        "-composites=false",
    ]
}

Describe the bug

go vet flag "-composites=false" is being ignored by the editor.
running go vet manually with this flag do not output any error.

Steps to reproduce the behavior:

example file hello.go:

package hello

import (
	"fmt"
	"image"
)

func hello() {
	fmt.Println([]image.CMYK{
		{[]uint8{}, 5, image.Rect(0, 0, 0, 0)},
	})
}

I get the following problem:

[
{
	"resource": "/root/go/src/aviv/hello/hello.go",
	"owner": "_generated_diagnostic_collection_name_#1",
	"severity": 4,
	"message": "image.CMYK composite literal uses unkeyed fields",
	"source": "composites",
	"startLineNumber": 10,
	"startColumn": 3,
	"endLineNumber": 10,
	"endColumn": 41
}
]

But running go vet -composites=false . manually show no error.
This does not replicate with a package main, nor with gopls turned off.

image

As far as I know, gopls does not "vet", vetting is still done by go vet, so I post the issue here and not on gopls repo - please let me know if I'm wrong.

Thank you,
Aviv

@hyangah
Copy link
Contributor

hyangah commented Jun 12, 2020

@avivdolev what do you see if you manually invoke vet using Command Palette -> "Go: Vet Current Package"?
The exact command line used for vet should appear in the "Go" Output channel.

Screen Shot 2020-06-12 at 10 12 25 AM

@avivdolev
Copy link
Author

The same output as you posted- no vet errors

@hyangah
Copy link
Contributor

hyangah commented Jun 12, 2020

you are using the language server.

gopls *does` vet check by default.
https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md#composite

Can you try to configure gopls to disable it? I think the configuration looks like

"gopls": {
   "analyses": {  "composite": false }
}

https://github.com/golang/tools/blob/master/gopls/doc/settings.md#analyses-mapstringbool

@stamblerre I think either we should disable direct launch of vet entirely if gopls is enabled, or have the setting ("go.vetFlags") be correctly applied to gopls. What do you think?

@avivdolev
Copy link
Author

Can you try to configure gopls to disable it? I think the configuration looks like

"gopls": {
   "analyses": {  "composite": false }
}

Doesn't seem to work (restarted gopls, reloaded vscode) :(
Double checked here:
https://github.com/golang/tools/blob/master/gopls/doc/analyzers.md
and the syntax seems right.

@hyangah
Copy link
Contributor

hyangah commented Jun 12, 2020

Sorry - a documentation bug. Try "composites".

"gopls": {
        "analyses": { "composites": false }
 },

@avivdolev
Copy link
Author

Worked! 🎉
Thank you :)

@hyangah
Copy link
Contributor

hyangah commented Jun 12, 2020

Glad that it worked.
Sent a PR to fix the doc.
Let's continue discussion about cleaning up settings in #197

@hyangah hyangah closed this as completed Jun 12, 2020
@golang golang locked and limited conversation to collaborators Jun 12, 2021
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

3 participants