24 lines
581 B
Go
24 lines
581 B
Go
package parse_test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.makaay.nl/mauricem/go-toml/parse"
|
|
)
|
|
|
|
func ExampleRun() {
|
|
doc, err := parse.Run("key = 'value'\nkey2 = 'another value'")
|
|
fmt.Println(doc, err)
|
|
|
|
doc, err = parse.Run("key = 'value'\n[table]\nanother_key = 'another one'")
|
|
fmt.Println(doc, err)
|
|
|
|
doc, err = parse.Run("key1 = 'valid'\nkey2 = invalid")
|
|
fmt.Println(doc, err)
|
|
|
|
// Output:
|
|
// {"key": "value", "key2": "another value"} <nil>
|
|
// {"key": "value", "table": {"another_key": "another one"}} <nil>
|
|
// {"key1": "valid"} unexpected input (expected a value) at line 2, column 8
|
|
}
|