Goconf
Golang config file parse module
Install / Use
/learn @Terry-Mao/GoconfREADME
Terry-Mao/goconf
Terry-Mao/goconf is an configuration file parse module.
Requeriments
- Go 1.2 or higher
Installation
Just pull Terry-Mao/goconf from github using go get:
# download the code
$ go get -u github.com/Terry-Mao/goconf
Usage
package main
import (
"fmt"
"github.com/Terry-Mao/goconf"
"time"
)
type TestConfig struct {
ID int `goconf:"core:id"`
Col string `goconf:"core:col"`
Ignore int `goconf:"-"`
Arr []string `goconf:"core:arr:,"`
Test time.Duration `goconf:"core:t_1:time"`
Buf int `goconf:"core:buf:memory"`
M map[int]string`goconf:"core:m:,"`
}
func main() {
conf := goconf.New()
if err := conf.Parse("./examples/conf_test.txt"); err != nil {
panic(err)
}
core := conf.Get("core")
if core == nil {
panic("no core section")
}
id, err := core.Int("id")
if err != nil {
panic(err)
}
fmt.Println(id)
tf := &TestConfig{}
if err := conf.Unmarshal(tf); err != nil {
panic(err)
}
fmt.Println(tf.ID)
}
Examples
# configuration examples
# this is comment, goconf will ignore it.
# this is the section name
[core]
# a key-value config which key is test and value is 1
test 1
# one mb
test1 1mb
# one second
test2 1s
# boolean
test3 true
# arr
arr hello,the,world
# map
m 1=hello,2=the,3=world
Documentation
Read the Terry-Mao/goconf documentation from a terminal
$ godoc github.com/Terry-Mao/goconf -http=:6060
Alternatively, you can goconf online.
Related Skills
node-connect
353.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
353.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
353.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
