From c694398da6684e6ed986f6c92a7f35ce8005c27a Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 6 Dec 2015 18:43:34 +0100 Subject: Experiment with config --- cmd/acme/config.go | 17 +++++++---------- cmd/acme/config_test.go | 11 +++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 cmd/acme/config_test.go (limited to 'cmd') diff --git a/cmd/acme/config.go b/cmd/acme/config.go index b880c11..c12732f 100644 --- a/cmd/acme/config.go +++ b/cmd/acme/config.go @@ -6,12 +6,16 @@ import ( "github.com/BurntSushi/toml" ) +type Config struct { + Account []Account +} + type Account struct { Mail string Key string Provider string Want []Want - Hook Hook + Hook []Hook } type Want struct { @@ -24,18 +28,11 @@ type Hook struct { CMD string } -func ReadConfig(fname string) Account { - var c Account +func ReadConfig(fname string) Config { + var c Config _, err := toml.DecodeFile(fname, &c) if err != nil { log.Fatal(err) } return c } - -/* -func main() { - a := ReadConfig("acme.toml") - log.Printf("%+v\n", a) -} -*/ diff --git a/cmd/acme/config_test.go b/cmd/acme/config_test.go new file mode 100644 index 0000000..0aa473a --- /dev/null +++ b/cmd/acme/config_test.go @@ -0,0 +1,11 @@ +package main + +import ( + "fmt" + "testing" +) + +func TestReadConfig(t *testing.T) { + a := ReadConfig("../../acme.toml") + t.Log(fmt.Sprintf("%+v\n", a)) +} -- cgit v1.2.3