aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/naoina/toml/encode.go
diff options
context:
space:
mode:
authorElad <theman@elad.im>2018-06-05 18:40:21 +0800
committerBalint Gabor <balint.g@gmail.com>2018-06-05 18:40:21 +0800
commit5bee5d69d743e2c91e8aa0f322e4de3834bb6664 (patch)
tree7157caf164b1882ed04eabc492f311a663a3fb0f /vendor/github.com/naoina/toml/encode.go
parentcbfb40b0aab093e1b612f3b16834894b2cc67882 (diff)
downloadgo-tangerine-5bee5d69d743e2c91e8aa0f322e4de3834bb6664.tar
go-tangerine-5bee5d69d743e2c91e8aa0f322e4de3834bb6664.tar.gz
go-tangerine-5bee5d69d743e2c91e8aa0f322e4de3834bb6664.tar.bz2
go-tangerine-5bee5d69d743e2c91e8aa0f322e4de3834bb6664.tar.lz
go-tangerine-5bee5d69d743e2c91e8aa0f322e4de3834bb6664.tar.xz
go-tangerine-5bee5d69d743e2c91e8aa0f322e4de3834bb6664.tar.zst
go-tangerine-5bee5d69d743e2c91e8aa0f322e4de3834bb6664.zip
vendor: added vendor packages necessary for the swarm-network-rewrite merge (#16792)
* vendor: added vendor packages necessary for the swarm-network-rewrite merge into ethereum master * vendor: removed multihash deps
Diffstat (limited to 'vendor/github.com/naoina/toml/encode.go')
-rw-r--r--vendor/github.com/naoina/toml/encode.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/vendor/github.com/naoina/toml/encode.go b/vendor/github.com/naoina/toml/encode.go
index ae6bfd575..15602f005 100644
--- a/vendor/github.com/naoina/toml/encode.go
+++ b/vendor/github.com/naoina/toml/encode.go
@@ -61,20 +61,26 @@ func (cfg *Config) NewEncoder(w io.Writer) *Encoder {
// Encode writes the TOML of v to the stream.
// See the documentation for Marshal for details about the conversion of Go values to TOML.
func (e *Encoder) Encode(v interface{}) error {
- rv := reflect.ValueOf(v)
+ var (
+ buf = &tableBuf{typ: ast.TableTypeNormal}
+ rv = reflect.ValueOf(v)
+ err error
+ )
+
for rv.Kind() == reflect.Ptr {
if rv.IsNil() {
return &marshalNilError{rv.Type()}
}
rv = rv.Elem()
}
- buf := &tableBuf{typ: ast.TableTypeNormal}
- var err error
+
switch rv.Kind() {
case reflect.Struct:
err = buf.structFields(e.cfg, rv)
case reflect.Map:
err = buf.mapFields(e.cfg, rv)
+ case reflect.Interface:
+ return e.Encode(rv.Interface())
default:
err = &marshalTableError{rv.Type()}
}