Example #1
0
File: example.go Project: knq/ini
func main() {
	inifile, err := ini.LoadString(data)
	if err != nil {
		fmt.Printf("ERROR: %s\n", err.Error())
		os.Exit(1)
	}

	//fmt.Printf(">> inifile: '%s'\n", inifile)
	val := inifile.GetKey("sect123.awesome")
	fmt.Printf(">> val: %s\n", val)
}
Example #2
0
File: test2.go Project: knq/ini
func main() {
	f, err := ini.LoadString(data)
	if err != nil {
		log.Fatalf("error: %s\n", err)
	}

	s := f.GetSection("some section")

	fmt.Printf("some section.key: %s\n", s.Get("key"))
	s.SetKey("key2", "another value")
	f.Write("out.ini")

	// create a gitconfig parser
	g, err := ini.LoadString(gitconfig)
	if err != nil {
		log.Fatalf("error: %s\n", err)
	}

	// setup gitconfig name/key manipulation functions
	g.SectionManipFunc = ini.GitSectionManipFunc
	g.SectionNameFunc = ini.GitSectionNameFunc

	fmt.Printf("difftool.gdmp.cmd: %s\n", g.GetKey("difftool.gdmp.cmd"))
}