func LoadFile(name string) error { f, err := os.Open(name) if os.IsNotExist(err) { f, err = os.Create(name) if err != nil { return err } err = toml.NewEncoder(f).Encode(Current) if err != nil { return err } err = f.Close() if err != nil { return err } return nil } if err != nil { return err } err = toml.NewDecoder(f).Decode(&Current) if err != nil { return err } return nil }
// NewEncoder produces a struct capable of writing TOML-encoded data to the // provided io.Writer. This function was originally provided by BurntSushi/toml func NewEncoder(w io.Writer) *toml.Encoder { return toml.NewEncoder(w) }
func WriteConfig(w io.Writer, d interface{}) error { enc := toml.NewEncoder(w) return enc.Encode(d) }