diff --git a/parsers/toml/go.mod b/parsers/toml/go.mod index 588f52e..a0931b9 100644 --- a/parsers/toml/go.mod +++ b/parsers/toml/go.mod @@ -3,7 +3,7 @@ module github.com/knadh/koanf/parsers/toml/v2 go 1.23.0 require ( - github.com/pelletier/go-toml/v2 v2.3.1 + github.com/pelletier/go-toml/v2 v2.4.3 github.com/stretchr/testify v1.9.0 ) diff --git a/parsers/toml/go.sum b/parsers/toml/go.sum index bb04a2e..ec194fa 100644 --- a/parsers/toml/go.sum +++ b/parsers/toml/go.sum @@ -1,7 +1,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pelletier/go-toml/v2 v2.3.1 h1:MYEvvGnQjeNkRF1qUuGolNtNExTDwct51yp7olPtrEc= -github.com/pelletier/go-toml/v2 v2.3.1/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY= +github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= diff --git a/parsers/toml/toml.go b/parsers/toml/toml.go index 7efb6d0..af770ac 100644 --- a/parsers/toml/toml.go +++ b/parsers/toml/toml.go @@ -21,11 +21,19 @@ func (p *TOML) Unmarshal(b []byte) (map[string]any, error) { return nil, err } + if len(outMap) == 0 { + return nil, nil + } + return outMap, nil } // Marshal marshals the given config map to TOML bytes. func (p *TOML) Marshal(o map[string]any) ([]byte, error) { + if len(o) == 0 { + return nil, nil + } + out, err := toml.Marshal(&o) if err != nil { return nil, err