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

Matt Joiner picture Matt Joiner · Mar 29, 2016 · Viewed 23.9k times · Source

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?

Answer

OneOfOne picture OneOfOne · Mar 29, 2016

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

a := A{B: b}

playground