Skip to content

Commit

Permalink
add slice example
Browse files Browse the repository at this point in the history
  • Loading branch information
kelseyhightower committed Mar 4, 2016
1 parent 82c0fe2 commit ac12b1f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export MYAPP_PORT=8080
export MYAPP_USER=Kelsey
export MYAPP_RATE="0.5"
export MYAPP_TIMEOUT="3m"
export MYAPP_USERS="rob,ken,robert"
```

Write some code:
Expand All @@ -39,6 +40,7 @@ type Specification struct {
Debug bool
Port int
User string
Users []string
Rate float32
Timeout time.Duration
}
Expand All @@ -54,6 +56,11 @@ func main() {
if err != nil {
log.Fatal(err.Error())
}

fmt.Println("Users:")
for _, u := range s.Users {
fmt.Printf(" %s\n", u)
}
}
```

Expand All @@ -65,6 +72,10 @@ Port: 8080
User: Kelsey
Rate: 0.500000
Timeout: 3m0s
Users:
rob
ken
robert
```

## Struct Tag Support
Expand Down Expand Up @@ -107,7 +118,7 @@ export MYAPP_DEBUG=true
```
```Go
type Specification struct {
ServiceHost string `envconfig:"SERVICE_HOST"`
Debug bool
ServiceHost string `envconfig:"SERVICE_HOST"`
Debug bool
}
```

0 comments on commit ac12b1f

Please sign in to comment.