1
2
3
4
5
6 package godebug
7
8 import "os"
9
10
11 func Get(key string) string {
12 return get(os.Getenv("GODEBUG"), key)
13 }
14
15
16 func get(s, key string) string {
17 for i := 0; i < len(s)-len(key)-1; i++ {
18 if i > 0 && s[i-1] != ',' {
19 continue
20 }
21 afterKey := s[i+len(key):]
22 if afterKey[0] != '=' || s[i:i+len(key)] != key {
23 continue
24 }
25 val := afterKey[1:]
26 for i, b := range val {
27 if b == ',' {
28 return val[:i]
29 }
30 }
31 return val
32 }
33 return ""
34 }
35
View as plain text