Provide Marshaler interface (#151)

The toml.Marhshaler interface allows marshalling custom objects implementing
the interface. Design based off json.Marshaler.
This commit is contained in:
Carolyn Van Slyck
2017-04-04 20:41:05 -05:00
committed by Thomas Pelletier
parent e32a2e0474
commit fe206efb84
3 changed files with 72 additions and 1 deletions
+3
View File
@@ -52,6 +52,9 @@ func tomlValueStringRepresentation(v interface{}) (string, error) {
return strconv.FormatFloat(value, 'f', -1, 32), nil
case string:
return "\"" + encodeTomlString(value) + "\"", nil
case []byte:
b, _ := v.([]byte)
return tomlValueStringRepresentation(string(b))
case bool:
if value {
return "true", nil