add bool example, fix misleading error message
diff --git a/gcfg_example_test.go b/gcfg_example_test.go
index fd47d8b..ea680ca 100644
--- a/gcfg_example_test.go
+++ b/gcfg_example_test.go
@@ -16,12 +16,29 @@
}{}
err := ParseString(&cfg, cfgStr)
if err != nil {
- log.Fatalf("Failed to parse INI data: %s", err)
+ log.Fatalf("Failed to parse gcfg data: %s", err)
}
fmt.Println(cfg.Section.Name)
// Output: value
}
+func ExampleParseString_bool() {
+ cfgStr := `; Comment line
+[section]
+switch=on`
+ cfg := struct {
+ Section struct {
+ Switch bool
+ }
+ }{}
+ err := ParseString(&cfg, cfgStr)
+ if err != nil {
+ log.Fatalf("Failed to parse gcfg data: %s", err)
+ }
+ fmt.Println(cfg.Section.Switch)
+ // Output: true
+}
+
func ExampleParseString_subsections() {
cfgStr := `; Comment line
[profile "A"]
@@ -37,7 +54,7 @@
}{}
err := ParseString(&cfg, cfgStr)
if err != nil {
- log.Fatalf("Failed to parse INI data: %s", err)
+ log.Fatalf("Failed to parse gcfg data: %s", err)
}
fmt.Printf("%s %s\n", cfg.Profile["A"].Color, cfg.Profile["B"].Color)
// Output: white black