Skip to content

Commit

Permalink
fix: gutil.IsMap judgment logic error (gogf#2953)
Browse files Browse the repository at this point in the history
  • Loading branch information
wlynxg authored Sep 13, 2023
1 parent e684eae commit ef1e18d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions container/gvar/gvar_z_unit_is_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package gvar_test
import (
"testing"

"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/test/gtest"
)
Expand Down Expand Up @@ -144,6 +145,10 @@ func TestVar_IsMap(t *testing.T) {
t.Assert(g.NewVar(int8(1)).IsMap(), false)
t.Assert(g.NewVar(uint8(1)).IsMap(), false)
})
gtest.C(t, func(t *gtest.T) {
t.Assert(gvar.New(gvar.New("asd")).IsMap(), false)
t.Assert(gvar.New(&g.Map{"k": "v"}).IsMap(), true)
})
}

func TestVar_IsStruct(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions internal/utils/utils_is.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func IsMap(value interface{}) bool {
)
for reflectKind == reflect.Ptr {
reflectValue = reflectValue.Elem()
reflectKind = reflectValue.Kind()
}
switch reflectKind {
case reflect.Map:
Expand Down

0 comments on commit ef1e18d

Please sign in to comment.