path := flag.String("config", "/etc/pt-client.conf", "path to configuration file")
flag.Parse()
$ ./a.out -config=/path/to/config.conf
$ go get github.com/dlintw/goconf
c, err := goconf.ReadConfigFile(*path)
if( err != nil ){
log.Println(err)
return false
}
val , err = c.GetInt("section", "name")
[section]
name = 5
// 5秒ごとに Foo
ticker := time.NewTicker(time.Duration(5) * time.Second);
for {
log.Println("Foo")
<- ticker.C;
}
func main(){
sig := make(chan os.Signal)
signal.Notify(sig, syscall.SIGINT)
signal.Notify(sig, syscall.SIGTERM)
s := <-sig
log.Printf("Exited with %d", s)
}