22 lines
421 B
Go
22 lines
421 B
Go
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
|
|
}
|