Skip to content

go vet warning "composite literal uses unkeyed fields" #13

Open
@printmaps

Description

@printmaps

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions