1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-12-01 22:51:45 +02:00

Some code improvements

* Remove shadowing of predeclared identifier: new.
* strings.ReplaceAll instead of strings.Replace with -1.
* Change strings.ToLower comparison to strings.EqualFold.
* Rewrite if-else-if-else chain as a switch.
This commit is contained in:
Kirill Motkov
2019-10-09 11:33:45 +03:00
parent 63da5c64db
commit e64e6fa514
4 changed files with 11 additions and 10 deletions

View File

@@ -40,7 +40,7 @@ func (cfg EnvOptions) LoadEnvForStruct(options interface{}) {
envName := field.Tag.Get("env")
cfgName := field.Tag.Get("cfg")
if cfgName == "" && flagName != "" {
cfgName = strings.Replace(flagName, "-", "_", -1)
cfgName = strings.ReplaceAll(flagName, "-", "_")
}
if envName == "" || cfgName == "" {
// resolvable fields must have the `env` and `cfg` struct tag