gamut icon indicating copy to clipboard operation
gamut copied to clipboard

go vet warning "composite literal uses unkeyed fields"

Open printmaps opened this issue 4 years ago • 0 comments

You can avoid this go vet warning:

...
gamut.Colors{
	{"Kadminumrot", gamut.Hex(fmt.Sprintf("#%02x%02x%02x", 230, 50, 0)), "Rot-1"},
	{Name: "Signalrot", Color: gamut.Hex(fmt.Sprintf("#%02x%02x%02x", 225, 0, 0)), Reference: "Rot-2"},
...

The first definition ("Kadminumrot", ...) produces the warning, the second definition (Name: "Signalrot", ...) does not.

https://stackoverflow.com/questions/54548441/composite-literal-uses-unkeyed-fields: Ignoring this vet warning has the potential to lead to really nasty and hard to track down runtime bugs, so you'd be better off if you were to always specify the keys of 3rd party structs explicitly.

It's a cosmetic change because you are the owner and not a user of the lib. The warning can easily be removed in your lib with search and replace.

printmaps avatar Dec 14 '20 14:12 printmaps