Skip to content

Commit 1315787

Browse files
committed
use go-cast instead of go-defaults
1 parent 09f849d commit 1315787

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

go.mod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module github.com/xgfone/gconf/v6
22

3-
require github.com/xgfone/go-defaults v0.15.0
3+
require (
4+
github.com/xgfone/go-cast v0.10.0
5+
github.com/xgfone/go-toolkit v0.15.0
6+
)
47

5-
go 1.22
8+
go 1.23

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
github.com/xgfone/go-defaults v0.15.0 h1:4hHgBE/biG7HcmN5pZiGcd0XVprz/jfCQhLog6QNmYo=
2-
github.com/xgfone/go-defaults v0.15.0/go.mod h1:RjyN5TK6hyaROkw2nyfchvCSCOch8rJ/zPO9nO4Y+EQ=
1+
github.com/xgfone/go-cast v0.10.0 h1:ugkGKoeps3u4Zb3/RLvTip94T0NRDetuw3GQKaFO/M0=
2+
github.com/xgfone/go-cast v0.10.0/go.mod h1:b+oRunHDgaYsEIELAEIgoWjcI1jawrttujVFgJzc1x0=
3+
github.com/xgfone/go-toolkit v0.15.0 h1:0xS3h8X1UhnbIbCo8niTpUeI3edjLQKzWWIMyM6a718=
4+
github.com/xgfone/go-toolkit v0.15.0/go.mod h1:eOWnIK/acAJOoqEOtWnvuY0Pbn6cZ0DP/Oeoyn17QHw=

opt_proxy_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import (
2121
"testing"
2222
"time"
2323

24-
"github.com/xgfone/go-defaults"
24+
"github.com/xgfone/go-toolkit/timex"
2525
)
2626

2727
func TestOptProxy(t *testing.T) {
28-
defaults.TimeLocation.Set(time.Local)
28+
timex.Location = time.Local
2929
Conf.reset()
3030

3131
boolopt := NewBool("bool", false, "bool")
@@ -162,7 +162,7 @@ func TestOptProxy(t *testing.T) {
162162
}
163163

164164
func TestOptGroupProxy(t *testing.T) {
165-
defaults.TimeLocation.Set(time.Local)
165+
timex.Location = time.Local
166166
config := New()
167167
group := config.Group("group1.group2")
168168
boolopt := group.NewBool("bool", false, "bool")

utils.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,25 @@ import (
2222
"strings"
2323
"time"
2424

25-
"github.com/xgfone/go-defaults"
25+
"github.com/xgfone/go-cast"
2626
)
2727

2828
// Some type converters, all of which have a default implementation,
2929
// but you can reset them to yourself implementations.
3030
var (
31-
ToBool = defaults.ToBool // func(any) (bool, error)
32-
ToInt64 = defaults.ToInt64 // func(any) (int64, error)
33-
ToUint64 = defaults.ToUint64 // func(any) (uint64, error)
34-
ToFloat64 = defaults.ToFloat64 // func(any) (float64, error)
35-
ToString = defaults.ToString // func(any) (string, error)
36-
ToDuration = defaults.ToDuration // func(any) (time.Duration, error)
37-
ToTime = defaults.ToTime // func(any) (time.Time, error)
38-
ToInt = toInt // func(any) (int, error)
39-
ToInt16 = toInt16 // func(any) (int16, error)
40-
ToInt32 = toInt32 // func(any) (int32, error)
41-
ToUint = toUint // func(any) (uint, error)
42-
ToUint16 = toUint16 // func(any) (uint16, error)
43-
ToUint32 = toUint32 // func(any) (uint32, error)
31+
ToBool = cast.ToBool // func(any) (bool, error)
32+
ToInt64 = cast.ToInt64 // func(any) (int64, error)
33+
ToUint64 = cast.ToUint64 // func(any) (uint64, error)
34+
ToFloat64 = cast.ToFloat64 // func(any) (float64, error)
35+
ToString = cast.ToString // func(any) (string, error)
36+
ToDuration = cast.ToDuration // func(any) (time.Duration, error)
37+
ToTime = cast.ToTime // func(any) (time.Time, error)
38+
ToInt = toInt // func(any) (int, error)
39+
ToInt16 = toInt16 // func(any) (int16, error)
40+
ToInt32 = toInt32 // func(any) (int32, error)
41+
ToUint = toUint // func(any) (uint, error)
42+
ToUint16 = toUint16 // func(any) (uint16, error)
43+
ToUint32 = toUint32 // func(any) (uint32, error)
4444

4545
// For string type, it will be split by the separator " " or ",".
4646
ToIntSlice = toIntSlice // func(any) ([]int, error)

0 commit comments

Comments
 (0)