uint16 type for port + env getter
This commit is contained in:
parent
979c7c4a4f
commit
f70d53c75c
2 changed files with 14 additions and 3 deletions
|
|
@ -39,3 +39,14 @@ func getEnvUint(key string, fallback uint) uint {
|
|||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
func getEnvPort(key string, fallback uint16) uint16 {
|
||||
if value, ok := os.LookupEnv(key); ok {
|
||||
num, err := strconv.ParseUint(value, 10, 16)
|
||||
if err != nil {
|
||||
return fallback
|
||||
}
|
||||
return uint16(num)
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue