Actually allocate storage before Unmarshall().
authorOllivier Robert <roberto@keltia.net>
Mon, 10 Apr 2017 19:35:54 +0200
changeset 44 f676c2646270
parent 43 e52d68c19cb0
child 45 c1fd96210492
Actually allocate storage before Unmarshall().
config.go
--- a/config.go	Mon Apr 10 17:16:37 2017 +0200
+++ b/config.go	Mon Apr 10 19:35:54 2017 +0200
@@ -57,10 +57,12 @@
 		return c, fmt.Errorf("Can not read %s", file)
 	}
 
-	err = toml.Unmarshal(buf, c)
+	cnf := Config{}
+	err = toml.Unmarshal(buf, &cnf)
 	if err != nil {
 		return c, fmt.Errorf("Error parsing toml %s: %v", file, err)
 	}
+	c = &cnf
 	return
 }