func readCfg(cfg string) { c, err := goconfig.ReadConfigFile(cfg) if err != nil { log.Fatalln(err) } //Site charset, _ := c.GetString("site", "charset") title, _ := c.GetString("site", "title") author, _ := c.GetString("site", "author") icon, _ := c.GetString("site", "icon") column, _ := c.GetString("site", "column") root, _ := c.GetString("site", "root") fmt.Println(charset, title, author, icon, column, root) }
func readIni() { c, err := goconfig.ReadConfigFile("config.cfg") if err != nil { log.Fatalln(err) } // result is string :http://www.example.com/some/path" url, _ := c.GetString("service-1", "url") maxclients, _ := c.GetInt64("service-1", "maxclients") // result is int 200 delegation, _ := c.GetBool("service-1", "delegation") // result is bool true // result is string "This is a multi-line\nentry" comments, _ := c.GetString("service-1", "comments") fmt.Println(url, maxclients, delegation, comments) }