// Decode unmarshals a string of TOML into a target configuration struct. func Decode(tomlBlob string, target interface{}) error { sreader := strings.NewReader(tomlBlob) decoder := toml.NewDecoder(sreader) err := decoder.Decode(target) if err != nil { return err } return nil }
// DecodeFile loads a TOML configuration from a provided path and unmarshals it // into a target configuration struct. func DecodeFile(path string, target interface{}) error { file, err := os.Open(path) if err != nil { return err } decoder := toml.NewDecoder(file) err = decoder.Decode(target) if err != nil { return err } return nil }