forked from jinzhu/configor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jinzhu#3 from c4s4/master
Provide a functional example code
- Loading branch information
Showing
1 changed file
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ Golang Configuration tool that support YAML, JSON, Shell Environment | |
# Usage | ||
|
||
```go | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/jinzhu/configor" | ||
) | ||
|
||
|
@@ -25,7 +28,26 @@ var Config = struct { | |
} | ||
}{} | ||
|
||
configor.Load(&Config, "config.yml", "config.json"...) | ||
func main() { | ||
configor.Load(&Config, "config.yml") | ||
fmt.Printf("config: %#v", Config) | ||
} | ||
``` | ||
|
||
With configuration file *config.yml*: | ||
|
||
```yaml | ||
APPName: test | ||
|
||
DB: | ||
Name: test | ||
User: test | ||
Password: test | ||
Port: 1234 | ||
|
||
Contacts: | ||
- Name: i test | ||
Email: [email protected] | ||
``` | ||
# Advanced Usage | ||
|