mirror of
https://github.com/weloe/token-go.git
synced 2025-10-08 00:40:21 +08:00
feat: add SerializerAdapter support custom serializer
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package util
|
||||
|
||||
import "fmt"
|
||||
|
||||
func HasNil(arr []interface{}) bool {
|
||||
for _, elem := range arr {
|
||||
if elem == nil {
|
||||
@@ -17,3 +19,10 @@ func HasStr(arr []string, str string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func InterfaceToBytes(data interface{}) ([]byte, error) {
|
||||
if b, ok := data.([]byte); ok {
|
||||
return b, nil
|
||||
}
|
||||
return nil, fmt.Errorf("unable to convert %T to []byte", data)
|
||||
}
|
||||
|
Reference in New Issue
Block a user