Skip to content

Commit 0e2a007

Browse files
committed
Use gconv.String instead of cast.ToString.
1 parent 4902eb7 commit 0e2a007

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

encoding/gproperties/gproperties.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
"github.com/gogf/gf/v2/errors/gerror"
1616
"github.com/gogf/gf/v2/internal/json"
17+
"github.com/gogf/gf/v2/util/gconv"
1718
"github.com/magiconair/properties"
18-
"github.com/spf13/cast"
1919
)
2020

2121
// Decode converts properties format to map.
@@ -57,7 +57,7 @@ func Encode(data map[string]interface{}) (res []byte, err error) {
5757
sort.Strings(keys)
5858

5959
for _, key := range keys {
60-
_, _, err := pr.Set(key, cast.ToString(flattened[key]))
60+
_, _, err := pr.Set(key, gconv.String(flattened[key]))
6161
if err != nil {
6262
err = gerror.Wrapf(err, `Sets the property key to the corresponding value failed.`)
6363
return nil, err
@@ -124,7 +124,7 @@ func flattenAndMergeMap(shadow map[string]interface{}, m map[string]interface{},
124124
case map[string]interface{}:
125125
m2 = val.(map[string]interface{})
126126
case map[interface{}]interface{}:
127-
m2 = cast.ToStringMap(val)
127+
m2 = gconv.Map(val)
128128
default:
129129
// immediate value
130130
shadow[strings.ToLower(fullKey)] = val

encoding/gproperties/gproperties_z_unit_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// This Source Code Form is subject to the terms of the MIT License.
44
// If a copy of the MIT was not distributed with this file,
55
// You can obtain one at https://github.com/gogf/gf.
6+
67
package gproperties_test
78

89
import (

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ require (
1010
github.com/go-redis/redis/v8 v8.11.4
1111
github.com/gorilla/websocket v1.5.0
1212
github.com/grokify/html-strip-tags-go v0.0.1
13+
github.com/kr/pretty v0.3.0 // indirect
1314
github.com/magiconair/properties v1.8.6
1415
github.com/olekukonko/tablewriter v0.0.5
15-
github.com/spf13/cast v1.5.0
1616
go.opentelemetry.io/otel v1.7.0
1717
go.opentelemetry.io/otel/sdk v1.7.0
1818
go.opentelemetry.io/otel/trace v1.7.0

go.sum

-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
1212
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
1313
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
1414
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
15-
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
16-
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
1715
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
1816
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
1917
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
@@ -81,8 +79,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
8179
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
8280
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
8381
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
84-
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
85-
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
8682
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
8783
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
8884
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=

0 commit comments

Comments
 (0)