Search code examples
gowarningssuppress-warnings

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


I'm running go vet on my CI tool, and started getting the error:

composite literal uses unkeyed fields

Because I'm instantiating

type A struct {
   *B
}

like this:

A{b} // b is of type *B

I don't care for this warning, and want to disable it on my go vet checks. How do I do this?


Solution

  • $ 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.