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

Addressing go vet errors #176

Open
dud225 opened this issue Aug 29, 2022 · 0 comments
Open

Addressing go vet errors #176

dud225 opened this issue Aug 29, 2022 · 0 comments

Comments

@dud225
Copy link

dud225 commented Aug 29, 2022

Hello

running make vet on the current code yields:

go vet .
# github.com/mercari/terraform-provider-spinnaker/spinnaker
spinnaker/resource_canary_config.go:66:2: struct field id has json tag but is not exported
spinnaker/resource_canary_config.go:67:2: struct field name has json tag but is not exported
spinnaker/resource_canary_config.go:68:2: struct field description has json tag but is not exported
spinnaker/resource_canary_config.go:69:2: struct field configVersion has json tag but is not exported
spinnaker/resource_canary_config.go:70:2: struct field applications has json tag but is not exported
spinnaker/resource_canary_config.go:71:2: struct field judge has json tag but is not exported
spinnaker/resource_canary_config.go:72:2: struct field metrics has json tag but is not exported
spinnaker/resource_canary_config.go:73:2: struct field templates has json tag but is not exported
spinnaker/resource_canary_config.go:74:2: struct field classifier has json tag but is not exported
spinnaker/resource_canary_config.go:78:2: struct field name has json tag but is not exported
spinnaker/resource_canary_config.go:79:2: struct field judgeConfigurations has json tag but is not exported
spinnaker/resource_canary_config.go:93:2: struct field groupWeights has json tag but is not exported

but when looking closer at the code, it seems that those tags aren't really used anywhere since the data passed to or from the Spinnaker API is conveyed within a type interface{}:

And when looking at the rest of the code it's similar: data are exchanged either through a type interface{} or []interface{} or map[string]interface{} which means that in all cases the tags information is lost since it only applies to a struct.
Those tags only express some minor case adjustements, but AFAIU all the named structs defined by that package are not intended to be exported anyway, so all those fields could be simply renamed in lowercase.
The actual translation from an interface{} or similar to a named type is realised by calls to mapstructure.Decode which performs a case-insensitive mapping, that's why this all works even if the json tags are ignored.

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