Disable go vet checks for "composite literal uses unkeyed fields"

You can disable it with the -composites=false flag: e.g.,

go vet -composites=false .

NB: go tool vet is deprecated


$ go doc cmd/vet

By default all checks are performed. If any flags are explicitly set to true, only those tests are run. Conversely, if any flag is explicitly set to false, only those tests are disabled. Thus -printf=true runs the printf check, -printf=false runs all checks except the printf check.

Unkeyed composite literals

Flag: -composites

Composite struct literals that do not use the field-keyed syntax.

You can disable it or you can fix the code instead:

a := A{B: b}

playground


If you're using the language server.

Gopls on by default in the VS Code Go extension

gopls does vet check by default.

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