5
5
6
6
Implements a simple way of handling environment values. Each environment field is simply reflected by a
7
7
variable inside the Go program. Out of the box handlers for the types ` bool ` , ` []byte ` , ` time.Duration ` ,
8
- ` int ` , ` []int ` , ` string ` and ` [ ]string` are provided. Other types can be added by using
8
+ ` int ` , ` []int ` , ` string ` , ` []string ` and ` map[string ]string` are provided. Other types can be added by using
9
9
the ` RegisterField ` function.
10
10
11
11
## Example
12
12
13
13
``` go
14
14
var (
15
- name = env.String (" NAME" , " joe" )
16
- age = env.Int (" AGE" , 24 )
15
+ name = env.String (" NAME" , " joe" )
16
+ age = env.Int (" AGE" , 24 )
17
+ shifts = env.StringMap (" SHIFTS" , map [string ]string {" monday" : " 9am - 5pm" })
17
18
)
18
19
19
20
func main () {
@@ -28,6 +29,7 @@ If the program is called with `-print-env`, all registered environment fields wo
28
29
``` bash
29
30
NAME=" joe"
30
31
AGE=" 24"
32
+ SHIFTS=" monday:\" 9am - 5pm\" "
31
33
```
32
34
33
35
By using ` -print-env -print-env-format long-bash ` , a description for each field is generated.
@@ -38,6 +40,9 @@ NAME="joe"
38
40
39
41
# Int field. The default value is '24'. Defined at .../main.go:10.
40
42
AGE=" 24"
43
+
44
+ # StringMap fields. The default value is 'monday:\"9am - 5pm\"'. Defined at .../main.go:9.
45
+ SHIFTS=" monday:\" 9am - 5pm\" "
41
46
```
42
47
43
48
## License
0 commit comments