It would be great if for a given struct field we could add comments for the different flag values like name, environment variable, description, etc - and have go generate create/update the corresponding Go struct tags for that field.
Example:
type MyConfig struct {
// flag:description Everything you write from here until the
// end of the comment group, including new lines
// will be considered the flag's description.
// flag:name some-field
// flag:env HTTP_DEFAULT_RESPONSE_CODE
// flag:value-name CODE
// flag:inherited
ResponseCode int
// flag:name target
// flag:env HTTP_TARGET
// flag:value-name URL
// flag:required
TargetURL string
// flag:args
Args []string
}
This would result in the following struct:
type MyConfig struct {
// flag:description Everything you write from here until the
// end of the comment group, including new lines
// will be considered the flag's description.
// flag:name some-field
// flag:env HTTP_DEFAULT_RESPONSE_CODE
// flag:value-name CODE
// flag:inherited
ResponseCode int `name:"some-field" env:"HTTP_DEFAULT_RESPONSE_CODE" valueName:"CODE" inherited:"true"`
// flag:name target
// flag:env HTTP_TARGET
// flag:value-name URL
// flag:required
TargetURL string `name:"target" env:"HTTP_TARGET" valueName:"URL" required:"true"`
// flag:args
Args []string `args:"true"`
}
The code generator would be idempotent, such that running it repeatedly would update the same tag and result in the same code, if the comments were unchanged.
It would be great if for a given struct field we could add comments for the different flag values like name, environment variable, description, etc - and have
go generatecreate/update the corresponding Go struct tags for that field.Example:
This would result in the following struct:
The code generator would be idempotent, such that running it repeatedly would update the same tag and result in the same code, if the comments were unchanged.