os.Expand시 없는 변수는 그대로 리턴

This commit is contained in:
2025-08-17 14:46:43 +09:00
parent c24d387761
commit 40baa86bd6

View File

@ -116,7 +116,13 @@ func LoadConfig[T any](outptr *T) error {
}
}
return json.Unmarshal([]byte(os.ExpandEnv(string(configContents))), outptr)
return json.Unmarshal([]byte(os.Expand(string(configContents), func(in string) string {
envval := os.Getenv(in)
if len(envval) == 0 {
return "$" + in
}
return envval
})), outptr)
}
type StorageAddr struct {