Browse Source

fix up examples

pull/16/head
Brett Langdon 11 years ago
parent
commit
1ffe6f5bfc
1 changed files with 7 additions and 6 deletions
  1. +7
    -6
      example_test.go

+ 7
- 6
example_test.go View File

@ -16,9 +16,9 @@ func Example() {
// Get a single value
if settings.Exists("global") {
// Get `global` casted as `StringValue`
value := settings.GetString("global")
fmt.Printf("global = \"%s\"\r\n", value.GetValue())
// Get `global` casted as a string
value, _ := settings.GetString("global")
fmt.Printf("global = \"%s\"\r\n", value)
}
// Get a nested value
@ -27,11 +27,11 @@ func Example() {
// You can also traverse down the sections manually
primary, err := settings.GetSection("primary")
value, err := primary.GetString("included_setting")
fmt.Printf("primary.included_setting = \"%s\"\r\n", value)
strVal, err := primary.GetString("included_setting")
fmt.Printf("primary.included_setting = \"%s\"\r\n", strVal)
// Convert settings to a map
settingsMap, err := settings.ToMap()
settingsMap := settings.ToMap()
fmt.Printf("global = \"%s\"\r\n", settingsMap["global"])
// Convert settings to JSON
@ -45,6 +45,7 @@ func ExampleParseFile() {
if err != nil {
panic(err)
}
fmt.Println(settings)
}
func ExampleParseString() {


Loading…
Cancel
Save