1 // Copyright 2017 Frank Schroeder. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 func ExampleLoad_iso88591() {
13 buf := []byte("key = ISO-8859-1 value with unicode literal \\u2318 and umlaut \xE4") // 0xE4 == ä
14 p, _ := Load(buf, ISO_8859_1)
20 // ISO-8859-1 value with unicode literal ⌘ and umlaut ä
23 func ExampleLoad_utf8() {
24 p, _ := Load([]byte("key = UTF-8 value with unicode character ⌘ and umlaut ä"), UTF8)
30 // UTF-8 value with unicode character ⌘ and umlaut ä
33 func ExampleProperties_GetBool() {
39 p, _ := Load([]byte(input), ISO_8859_1)
40 fmt.Println(p.GetBool("key", false))
41 fmt.Println(p.GetBool("key2", false))
42 fmt.Println(p.GetBool("key3", false))
43 fmt.Println(p.GetBool("key4", false))
44 fmt.Println(p.GetBool("keyX", false))
53 func ExampleProperties_GetString() {
54 p, _ := Load([]byte("key=value"), ISO_8859_1)
55 v := p.GetString("another key", "default value")
62 // Decode some key/value pairs with expressions
63 p, err := Load([]byte("key=value\nkey2=${key}"), ISO_8859_1)
69 if v, ok := p.Get("key"); ok {
74 if _, ok := p.Get("does not exist"); !ok {
75 fmt.Println("invalid key")
78 // Get a key with a default value
79 v := p.GetString("does not exist", "some value")
82 // Dump the expanded key/value pairs of the Properties
83 fmt.Println("Expanded key/value pairs")
90 // Expanded key/value pairs