got dotenv parsing working
CI / Detect changed paths (pull_request) Successful in 4s
CI / Odin unit tests and build (pull_request) Successful in 41s
CI / API unit tests and lint (pull_request) Failing after 33s
CI / Infra unit tests, vet, and preview (pull_request) Successful in 26s

This commit is contained in:
2026-09-08 01:09:55 -06:00
parent fade4a17dc
commit 3a037b5fd3
4 changed files with 22 additions and 12 deletions
+7 -5
View File
@@ -38,8 +38,9 @@ parse :: proc(src: string, allocator := context.allocator) -> map[string]string
}
// real process env vars win over the file
if override, found := os.lookup_env(key, context.temp_allocator); found {
value = override
if override, found := os.lookup_env(key, allocator); found {
result[strings.clone(key, allocator)] = override
continue
}
// clone so the map outlives the source buffer (e.g. a freed file read)
@@ -63,10 +64,11 @@ parse_file :: proc(filename: string, allocator := context.allocator) -> (map[str
// destroy frees the cloned keys/values and the map itself. Use it to release
// a map returned by parse/parse_file (plain delete does not free the strings).
destroy :: proc(env: map[string]string) {
// Any allocator passed to parse/parse_file must be passed here too.
destroy :: proc(env: map[string]string, allocator := context.allocator) {
for key, value in env {
delete(key)
delete(value)
delete(key, allocator)
delete(value, allocator)
}
delete(env)
}