Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
printmaps opened this issue Dec 14, 2020 · 0 comments
Open

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

printmaps opened this issue Dec 14, 2020 · 0 comments

Comments

@printmaps
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant