generated code file path.
formatters
is the list of command to format generated code file.
For example,
formatters:
- gofmt -l -s -w
the target file path is added to each command.
default
defines the parameter's default configuration.
If each param's configuration overwrites the default configuration.
The default
configuration is optional.
- default.env.bind
- default.env.prefix
- default.flag.bind
param.name
is the viper key.
param.type
is the paramter's type.
If it is not set, the type is inferred using the default value.
For example, if param.default
is 10
, param.type
is inferred as "int"
.
params[].default
is the default value of the parameter.
viper.SetDefault(portKey, 3000)
pflag.IntP("port", "p", 3000, "app port number")
env.bind
viper.BindEnv(portKey, "SAMPLE_PORT")
flag.bind
pflag.IntP("port", "p", 3000, "app port number")
viper.BindPFlag(portKey, pflag.Lookup("port"))
pflag.Parse()
Each param's end.bind
and flag.bind
is true if each param's other configuration such as env.prefix
defines explicitly.
flag.description
is the description of the flag.
If it is not set, params[].description
is used.
pflag.IntP("port", "p", 3000, "app port number")
flag.name
is the flag name.
pflag.IntP("port", "p", 3000, "app port number")
Optional.
If flag.short
is set,
pflag.IntP("port", "p", 3000, "app port number")
otherwise
pflag.Int("port", 3000, "app port number")
env.name
is the binded environment variable name.
The default value is {{env.prefix}}{{param.name}}
.
env.prefix
is the prefix of environment variable name.
If env.name
is set, env.prefix
is ignored.