utils

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToStr

func AnyToStr(obj interface{}) string

任意类型转成字符串

Example
var u1 uInt = 9845
var f chan int
fmt.Println(AnyToStr(u1))
fmt.Println(AnyToStr(f))
Output:

9845
chan int

func Base64Decode added in v1.1.3

func Base64Decode(s string) (string, error)

func Base64DecodeBytes added in v1.1.3

func Base64DecodeBytes(s []byte) (result []byte, err error)

func Base64Encode added in v1.1.3

func Base64Encode(s string) (result string)

func Base64EncodeBytes added in v1.1.3

func Base64EncodeBytes(s []byte) (result []byte)

func BytesToString

func BytesToString(b []byte) string

字节组转字符串

func BytesToStruct

func BytesToStruct(bytes []byte, obj interface{}) error

func GZipBytes

func GZipBytes(data []byte) ([]byte, error)

压缩

func GetType

func GetType(val interface{}) reflect.Type

func GetTypeFullName

func GetTypeFullName(val interface{}) (string, string, string)

func GetTypeName

func GetTypeName(val interface{}) string

func IfElseInt

func IfElseInt(condition bool, valt int, valf int) int

func IndexOf

func IndexOf(ary []string, str string, isMatchCase bool) (index int)

获取字符串在字符串数组中的位置 -1 表示字符串不在数组中

func IndexOfMatchCase

func IndexOfMatchCase(ary []string, str string) (index int)

获取字符串在字符串数组中的位置

 区分大小写
	-1 表示字符串不在数组中

func IndexOfWithoutCase

func IndexOfWithoutCase(ary []string, str string) (index int)

获取字符串在字符串数组中的位置

 不区分大小写
	-1 表示字符串不在数组中

func Int64Max

func Int64Max(x, y int64) int64

func Int64Min

func Int64Min(x, y int64) int64

func IntMax

func IntMax(x, y int) int

func IntMin

func IntMin(x, y int) int

func IsDirExists

func IsDirExists(path string) (bool, error)

判断目录是否存在

func IsObjectNil

func IsObjectNil(obj interface{}) bool

判断对象是否为空

func IsStrEmptyOrNull

func IsStrEmptyOrNull(str string) bool

判断字符串是否为空或空字符串

func Md5 added in v1.1.3

func Md5(s string) (result string)

func Md5Bytes added in v1.1.3

func Md5Bytes(p []byte) (result string)

func Sha1 added in v1.1.3

func Sha1(s string) (result string)

func Sha1Bytes added in v1.1.3

func Sha1Bytes(p []byte) (result string)

func Sha256 added in v1.1.3

func Sha256(s string) (result string)

func Sha256Bytes added in v1.1.3

func Sha256Bytes(p []byte) (result string)

func Sha512 added in v1.1.3

func Sha512(s string) (result string)

func Sha512Bytes added in v1.1.3

func Sha512Bytes(p []byte) (result string)

func StringToBytes

func StringToBytes(s string) []byte

字符串转字节组

func StructToBytes

func StructToBytes(obj interface{}) ([]byte, error)

func UGZipBytes

func UGZipBytes(data []byte) ([]byte, error)

解压

func UZipBytes

func UZipBytes(data []byte) ([]byte, error)

zip解压

func ZipBytes

func ZipBytes(data []byte) ([]byte, error)

zip压缩

Types

type Closer

type Closer interface {
	Close() error
}

type XTime

type XTime time.Time

func (XTime) Format

func (self XTime) Format(format string) string

用 %y %M %d 的格式来格式化时间

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL