Skip to content

Commit

Permalink
fix(cristalhq#152): migrate toml package
Browse files Browse the repository at this point in the history
  • Loading branch information
wweir committed Aug 26, 2024
1 parent b4a66c3 commit 6d6ee75
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
8 changes: 5 additions & 3 deletions aconfigtoml/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module github.com/cristalhq/aconfig/aconfigtoml

go 1.16
go 1.21.0

toolchain go1.23.0

require (
github.com/BurntSushi/toml v1.1.0
github.com/cristalhq/aconfig v0.17.0
github.com/cristalhq/aconfig v0.18.5
github.com/pelletier/go-toml/v2 v2.2.3
)
16 changes: 12 additions & 4 deletions aconfigtoml/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/cristalhq/aconfig v0.17.0 h1:VYqg0YOM5yUEx0KH/VwUYF2e/PNI7dcUE66y+xEx73s=
github.com/cristalhq/aconfig v0.17.0/go.mod h1:NXaRp+1e6bkO4dJn+wZ71xyaihMDYPtCSvEhMTm/H3E=
github.com/cristalhq/aconfig v0.18.5 h1:QqXH/Gy2c4QUQJTV2BN8UAuL/rqZ3IwhvxeC8OgzquA=
github.com/cristalhq/aconfig v0.18.5/go.mod h1:NXaRp+1e6bkO4dJn+wZ71xyaihMDYPtCSvEhMTm/H3E=
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.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
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=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions aconfigtoml/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package aconfigtoml
import (
"io/fs"

"github.com/BurntSushi/toml"
"github.com/pelletier/go-toml/v2"
)

// Decoder of TOML files for aconfig.
Expand All @@ -28,7 +28,7 @@ func (d *Decoder) DecodeFile(filename string) (map[string]interface{}, error) {
defer f.Close()

var raw map[string]interface{}
if _, err := toml.DecodeReader(f, &raw); err != nil {
if err := toml.NewDecoder(f).Decode(&raw); err != nil {
return nil, err
}
return raw, nil
Expand Down
8 changes: 6 additions & 2 deletions aconfigtoml/toml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ var configEmbed embed.FS

func TestTOMLEmbed(t *testing.T) {
var cfg struct {
Foo string
Bar string
Foo string
Bar string
Foobar []struct {
Foo string
Bar string
}
}
loader := aconfig.LoaderFor(&cfg, aconfig.Config{
SkipDefaults: true,
Expand Down

0 comments on commit 6d6ee75

Please sign in to comment.