Beispiel #1
0
func TestParseReader(t *testing.T) {
	settings, err := forge.ParseReader(testConfigReader)
	if err != nil {
		t.Fatal(err)
	}
	values := settings.ToMap()
	assertDirectives(values, t)
}
Beispiel #2
0
func BenchmarkParseReader(b *testing.B) {
	for i := 0; i < b.N; i++ {
		exampleConfigReader.Seek(0, 0)
		_, err := forge.ParseReader(exampleConfigReader)
		if err != nil {
			b.Fatal(err)
		}
	}
}
Beispiel #3
0
func ExampleParseReader() {
	// Parse a `SectionValue` from []byte containing the config
	data := []byte("amount = 500;")
	reader := bytes.NewBuffer(data)
	settings, err := forge.ParseReader(reader)
	if err != nil {
		panic(err)
	}

	fmt.Println(settings.GetInteger("amount"))
}