Skip to content

Commit 77fc1c3

Browse files
committed
feat!: drop toml v1 support
Signed-off-by: Mark Sagi-Kazar <[email protected]>
1 parent e42b933 commit 77fc1c3

File tree

7 files changed

+10
-167
lines changed

7 files changed

+10
-167
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
matrix:
4545
os: [ubuntu-latest, macos-latest, windows-latest]
4646
go: ['1.16', '1.17', '1.18', '1.19']
47-
tags: ['', 'viper_toml1']
47+
tags: ['']
4848
env:
4949
GOFLAGS: -mod=readonly
5050

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/hashicorp/hcl v1.0.0
88
github.com/magiconair/properties v1.8.7
99
github.com/mitchellh/mapstructure v1.5.0
10-
github.com/pelletier/go-toml v1.9.5
1110
github.com/pelletier/go-toml/v2 v2.0.6
1211
github.com/sagikazarmark/crypt v0.8.0
1312
github.com/spf13/afero v1.9.3

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW
480480
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
481481
github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY=
482482
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
483-
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
484-
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
485483
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
486484
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
487485
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

internal/encoding/toml/codec.go

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,16 @@
1-
//go:build viper_toml1
2-
// +build viper_toml1
3-
41
package toml
52

63
import (
7-
"github.com/pelletier/go-toml"
4+
"github.com/pelletier/go-toml/v2"
85
)
96

107
// Codec implements the encoding.Encoder and encoding.Decoder interfaces for TOML encoding.
118
type Codec struct{}
129

1310
func (Codec) Encode(v map[string]interface{}) ([]byte, error) {
14-
t, err := toml.TreeFromMap(v)
15-
if err != nil {
16-
return nil, err
17-
}
18-
19-
s, err := t.ToTomlString()
20-
if err != nil {
21-
return nil, err
22-
}
23-
24-
return []byte(s), nil
11+
return toml.Marshal(v)
2512
}
2613

2714
func (Codec) Decode(b []byte, v map[string]interface{}) error {
28-
tree, err := toml.LoadBytes(b)
29-
if err != nil {
30-
return err
31-
}
32-
33-
tmap := tree.ToMap()
34-
for key, value := range tmap {
35-
v[key] = value
36-
}
37-
38-
return nil
15+
return toml.Unmarshal(b, &v)
3916
}

internal/encoding/toml/codec2.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

internal/encoding/toml/codec2_test.go

Lines changed: 0 additions & 108 deletions
This file was deleted.

internal/encoding/toml/codec_test.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//go:build viper_toml1
2-
// +build viper_toml1
3-
41
package toml
52

63
import (
@@ -29,17 +26,16 @@ list = [
2926
`
3027

3128
// encoded form of the data
32-
const encoded = `key = "value"
33-
list = ["item1", "item2", "item3"]
29+
const encoded = `key = 'value'
30+
list = ['item1', 'item2', 'item3']
3431
3532
[map]
36-
key = "value"
33+
key = 'value'
3734
3835
[nested_map]
39-
40-
[nested_map.map]
41-
key = "value"
42-
list = ["item1", "item2", "item3"]
36+
[nested_map.map]
37+
key = 'value'
38+
list = ['item1', 'item2', 'item3']
4339
`
4440

4541
// Viper's internal representation

0 commit comments

Comments
 (0)