I\'m running go vet on my CI tool, and started getting the error:
composite literal uses unkeyed fields
Because I\'m instantiating
If you are using VS code, you have to manually set the flag under settings
settings > Extensions > Go
Scroll down to "Vet Flags" section
Add Item and add the flag
-composites=false .
Click ok.
Save one of your files again or restart VS code to see the effect.
$ 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.
go tool vet -composites=false .
You can disable it or you can fix the code instead:
a := A{B: b}
playground
You can disable it with the -composites=false
flag: e.g.,
go vet -composites=false .
NB: go tool vet
is deprecated