Skip to content

Commit

Permalink
👔 update: update deps to latest and update some comments and tests
Browse files Browse the repository at this point in the history
- gookit/color to v1.5.4
  • Loading branch information
inhere committed Jul 24, 2023
1 parent fbe027e commit 33b57ac
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
12 changes: 9 additions & 3 deletions byteutil/encoder.go
Expand Up @@ -5,6 +5,12 @@ import (
"encoding/hex"
)

// BytesEncodeFunc type
type BytesEncodeFunc func(src []byte) []byte

// BytesDecodeFunc type
type BytesDecodeFunc func(src []byte) ([]byte, error)

// BytesEncoder interface
type BytesEncoder interface {
Encode(src []byte) []byte
Expand All @@ -13,12 +19,12 @@ type BytesEncoder interface {

// StdEncoder implement the BytesEncoder
type StdEncoder struct {
encodeFn func(src []byte) []byte
decodeFn func(src []byte) ([]byte, error)
encodeFn BytesEncodeFunc
decodeFn BytesDecodeFunc
}

// NewStdEncoder instance
func NewStdEncoder(encFn func(src []byte) []byte, decFn func(src []byte) ([]byte, error)) *StdEncoder {
func NewStdEncoder(encFn BytesEncodeFunc, decFn BytesDecodeFunc) *StdEncoder {
return &StdEncoder{
encodeFn: encFn,
decodeFn: decFn,
Expand Down
2 changes: 1 addition & 1 deletion conv.go
Expand Up @@ -76,7 +76,7 @@ func BaseTypeVal(val any) (value any, err error) {
return reflects.BaseTypeVal(reflect.ValueOf(val))
}

// BoolString convert
// BoolString convert bool to string
func BoolString(bl bool) string {
return strconv.FormatBool(bl)
}
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -3,7 +3,7 @@ module github.com/gookit/goutil
go 1.18

require (
github.com/gookit/color v1.5.3
github.com/gookit/color v1.5.4
golang.org/x/sync v0.3.0
golang.org/x/sys v0.10.0
golang.org/x/term v0.10.0
Expand Down
6 changes: 3 additions & 3 deletions go.sum
@@ -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/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
Expand Down
2 changes: 2 additions & 0 deletions netutil/httpctype/content_type.go
Expand Up @@ -30,6 +30,8 @@ const (
PROTOBUF = "application/x-protobuf"

Form = "application/x-www-form-urlencoded"
// FormUtf8 for form data with charset=utf-8
FormUtf8 = "application/x-www-form-urlencoded; charset=utf-8"
// FormData for upload file
FormData = "multipart/form-data"

Expand Down
2 changes: 1 addition & 1 deletion sysutil/process/procutil.go
Expand Up @@ -42,7 +42,7 @@ func PIDByName(keywords string) int {
return 0
}

return strutil.Int2(string(byteutil.FirstLine(output)))
return strutil.SafeInt(string(byteutil.FirstLine(output)))
}

return 0
Expand Down
11 changes: 9 additions & 2 deletions testutil/fakeobj/fs.go
Expand Up @@ -59,6 +59,9 @@ type FileInfo struct {
Mod fs.FileMode
Mt time.Time

// Path full path
Path string

Contents string
CloseErr error
offset int
Expand All @@ -71,8 +74,12 @@ func NewFile(fpath string) *FileInfo {

// NewFileInfo instance
func NewFileInfo(fpath string, isDir ...bool) *FileInfo {
isd := basefn.FirstOr(isDir, false)
return &FileInfo{Dir: isd, Nam: path.Base(fpath), Mod: fs.ModePerm}
return &FileInfo{
Dir: basefn.FirstOr(isDir, false),
Nam: path.Base(fpath),
Mod: fs.ModePerm,
Path: fpath,
}
}

// WithBody set file body contents
Expand Down

0 comments on commit 33b57ac

Please sign in to comment.