@@ -28,13 +28,14 @@ import (
28
28
)
29
29
30
30
type config struct {
31
- Home string ` env:"HOME"`
32
- Port int ` env:"PORT" envDefault:"3000"`
33
- Password string ` env:"PASSWORD,unset"`
34
- IsProduction bool ` env:"PRODUCTION"`
35
- Hosts []string ` env:"HOSTS" envSeparator:":"`
36
- Duration time.Duration ` env:"DURATION"`
37
- TempFolder string ` env:"TEMP_FOLDER,expand" envDefault:"${HOME}/tmp"`
31
+ Home string ` env:"HOME"`
32
+ Port int ` env:"PORT" envDefault:"3000"`
33
+ Password string ` env:"PASSWORD,unset"`
34
+ IsProduction bool ` env:"PRODUCTION"`
35
+ Hosts []string ` env:"HOSTS" envSeparator:":"`
36
+ Duration time.Duration ` env:"DURATION"`
37
+ TempFolder string ` env:"TEMP_FOLDER,expand" envDefault:"${HOME}/tmp"`
38
+ StringInts map [string ]int ` env:"MAP_STRING_INT"`
38
39
}
39
40
40
41
func main () {
@@ -50,8 +51,8 @@ func main() {
50
51
You can run it like this:
51
52
52
53
``` sh
53
- $ PRODUCTION=true HOSTS=" host1:host2:host3" DURATION=1s go run main.go
54
- {Home:/your/home Port:3000 IsProduction:true Hosts:[host1 host2 host3] Duration:1s}
54
+ $ PRODUCTION=true HOSTS=" host1:host2:host3" DURATION=1s MAP_STRING_INT=k1:1,k2:2 go run main.go
55
+ {Home:/your/home Port:3000 IsProduction:true Hosts:[host1 host2 host3] Duration:1s StringInts:map[k1:1 k2:2] }
55
56
```
56
57
57
58
## Caveats
0 commit comments