Skip to content

Commit

Permalink
⬆️ chore(dep): update the gookit/goutil to v0.6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 6, 2023
1 parent 9dc5969 commit aba53f6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/gookit/color v1.5.3
github.com/gookit/goutil v0.6.7
github.com/gookit/goutil v0.6.8
golang.org/x/crypto v0.7.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/gookit/color v1.5.3 h1:twfIhZs4QLCtimkP7MOxlF3A0U/5cDPseRT9M/+2SCE=
github.com/gookit/color v1.5.3/go.mod h1:NUzwzeehUfl7GIb36pqId+UGmRfQcU/WiiyTTeNjHtE=
github.com/gookit/goutil v0.6.7 h1:Sz0y5eslPZ8M2lUhRaSMnwEeX5nb9z7SoCsw0ZbMwe4=
github.com/gookit/goutil v0.6.7/go.mod h1:ti+JpLBGSN83ga6SSZa6uozhntToWSzOPm2z1hvpQSc=
github.com/gookit/goutil v0.6.8 h1:B2XXSCGav5TXWtKRT9i/s/owOLXXB7sY6UsfqeSLroE=
github.com/gookit/goutil v0.6.8/go.mod h1:u+Isykc6RQcZ4GQzulsaGm+Famd97U5Tzp3aQyo+jyA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
Expand Down
14 changes: 11 additions & 3 deletions show/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type Items struct {
keyMaxWidth int
}

// NewItems create a Items for data.
// NewItems create an Items for data.
func NewItems(data any) *Items {
items := &Items{
data: data,
Expand All @@ -145,7 +145,9 @@ func NewItems(data any) *Items {
}

var keyWidth int
switch rv.Kind() {
kind := rv.Kind()

switch kind {
case reflect.Map:
mapKeys := rv.MapKeys()
for i := 0; i < len(mapKeys); i++ {
Expand Down Expand Up @@ -188,8 +190,14 @@ func NewItems(data any) *Items {
items.List = append(items.List, item)
keyWidth = item.maxLen(keyWidth)
}
case reflect.String:
items.List = append(items.List, newItem("", rv, 0))
default:
panic("GCLI: invalid data type, only allow: array, map, slice, struct")
if reflects.IsAnyInt(kind) {
items.List = append(items.List, newItem("", rv, 0))
} else {
panic("GCLI.show: unsupported data type: " + rv.Kind().String())
}
}

// settings
Expand Down

0 comments on commit aba53f6

Please sign in to comment.