fix: restore int64 environment parsing
This commit is contained in:
1 parent
a4f897572c
commit
775a5520b6
2 files changed
+54
No files matched your search
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// envInt64 returns the parsed environment value or fallback when the variable
|
||||
// is unset, empty, or not a valid base-10 int64.
|
||||
func envInt64(name string, fallback int64) int64 {
|
||||
value := strings.TrimSpace(os.Getenv(name))
|
||||
if value == "" {
|
||||
return fallback
|
||||
}
|
||||
parsed, err := strconv.ParseInt(value, 10, 64)
|
||||
if err != nil {
|
||||
return fallback
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
Reference in new issue
Block a user