uint16 type for port + env getter

This commit is contained in:
nquidox 2026-04-03 11:45:22 +03:00
parent 979c7c4a4f
commit f70d53c75c
2 changed files with 14 additions and 3 deletions

View file

@ -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
}