Spaces:
Runtime error

File size: 406 Bytes
c704b7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package utils

import (
	"os"
	"strings"
)

func Ptr[T any](v T) *T {
	return &v
}

func GetEnv(key string) string {
	// 1. Normal env
	if val := os.Getenv(key); val != "" {
		return val
	}

	// 2. File-based secret
	if file := os.Getenv(key + "_FILE"); file != "" {
		data, err := os.ReadFile(file)
		if err == nil {
			return strings.TrimSpace(string(data))
		} else {
			panic(err)
		}
	}

	return ""
}