util

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UTF8    = Charset("UTF-8")
	GB18030 = Charset("GB18030")
	GBK     = Charset("GBK")
)

Variables

This section is empty.

Functions

func AssertMarshal

func AssertMarshal(v interface{}, params ...int) string

func Base64Decode

func Base64Decode(str string) (string, error)

base64 decode

func Base64Encode

func Base64Encode(str string) string

base64 encode

func ConvertByte2String

func ConvertByte2String(byte []byte, charset Charset) string

func Des3Decrypt

func Des3Decrypt(key3Des []byte, sec string) (string, error)

3des解密

func Des3Encrypt

func Des3Encrypt(key3Des []byte, source string) (string, error)

3des加密

func DesDecrypt

func DesDecrypt(crypted, key []byte) ([]byte, error)

func DesEncrypt

func DesEncrypt(origData, key []byte) ([]byte, error)

func ExecCmd

func ExecCmd(dir string, str string) (string, error)

执行命令

func ExecCmd2

func ExecCmd2(ctx context.Context, runDir string, cmd string) (string, error)

func FunFuncName

func FunFuncName() string

func FuncName added in v1.2.2

func FuncName() string

func GbkToUtf8

func GbkToUtf8(s []byte) ([]byte, error)

func GetBinDir added in v1.1.1

func GetBinDir() string

func GetBinDirNew added in v1.1.6

func GetBinDirNew() string

func GetBinName added in v1.1.4

func GetBinName() string

func GetBody added in v1.2.2

func GetBody(r *http.Request) []byte

func GetDateByN

func GetDateByN(n int) int64

获取当前日期前后n天对应的日期证书,0代表获取当前日期整数

func GetFieldName

func GetFieldName(t reflect.Type) (map[string]string, error)

func GetHmac

func GetHmac(key string, data string) string

加密哈希

func GetHmacSha256

func GetHmacSha256(key string, data string) string

func GetIPv4 added in v1.3.2

func GetIPv4() string

获取本机ip

func GetIndexByWeigth

func GetIndexByWeigth(data []int) int

func GetLocalMac added in v1.3.5

func GetLocalMac() string

获取本机第一张网卡的mac地址

func GetMd5

func GetMd5(data string) string

func GetMysqlParam

func GetMysqlParam(n int) string

func GetPidByWindows added in v1.1.2

func GetPidByWindows(name string) (rets []int)

func GetPosInfo

func GetPosInfo() (string, int)

func GetPosInfoSplit added in v1.1.1

func GetPosInfoSplit() string

func GetPosInfoStr

func GetPosInfoStr() string

func GetSecondByDay00

func GetSecondByDay00() int64

获取当前日期(20170802)零点对应的Unix时间戳

func GetSecondFromDay

func GetSecondFromDay() int64

获取整天以来的秒数

func GetSecondFromHour

func GetSecondFromHour() int64

获取整点以来的秒数

func GetSecondFromMonth

func GetSecondFromMonth() int64

获取整月以来的秒数

func GetSecondFromWeek

func GetSecondFromWeek() int64

获取整周以来的秒数

func GetSha1

func GetSha1(data string) string

func GetSignal

func GetSignal() int

func GetTDayByUnixTime

func GetTDayByUnixTime(nowUnix int64) int64

根据时间戳获取对应日期整数

func HideStar added in v1.3.2

func HideStar(str string) (result string)

func IPIPToUint32 added in v1.2.7

func IPIPToUint32(ipnr net.IP) (sum uint32, err error)

func IPStringToUint32 added in v1.2.7

func IPStringToUint32(ipString string) (sum uint32, err error)

func IPUint32ToIP added in v1.2.8

func IPUint32ToIP(intIP uint32) net.IP

func IsGBK

func IsGBK(data []byte) bool

func IsUtf8

func IsUtf8(data []byte) bool

func MonitorStatus added in v1.1.2

func MonitorStatus(interTime time.Duration, param ...func() string)

func PKCS5Padding

func PKCS5Padding(ciphertext []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func PathExists

func PathExists(path string) bool

判断文件夹是否存在

func PidByBinName added in v1.1.2

func PidByBinName(binName string) []int

func Profiling

func Profiling(msg string) func()

统计某函数执行时间 使用方式 defer utils.Profiling("test")()

func RandGenerate added in v1.3.4

func RandGenerate(n int) string

func RandMN

func RandMN(min int, max int) int

[min,max)

func RsaDecrypt

func RsaDecrypt(privateKey []byte, origData string) ([]byte, error)

rsa解密

func RsaEncrypt

func RsaEncrypt(publicKey []byte, data []byte) (string, error)

rsa加密

func RunFuncName

func RunFuncName() string

func RunPprof added in v1.1.2

func RunPprof(addr string)

RunPprof addr ip:port

func TarGz added in v1.2.3

func TarGz(src string, dest string) error

func TripleDesDecrypt

func TripleDesDecrypt(crypted, key []byte) ([]byte, error)

3DES解密

func TripleDesEncrypt

func TripleDesEncrypt(origData, key []byte) ([]byte, error)

3DES加密

func UrlDecode

func UrlDecode(str string) (string, error)

url decode string

func UrlEncode

func UrlEncode(str string) string

url encode string, is + not %20

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

func ZeroPadding

func ZeroPadding(ciphertext []byte, blockSize int) []byte

func ZeroUnPadding

func ZeroUnPadding(origData []byte) []byte

Types

type Charset

type Charset string

type TplJson

type TplJson struct {
	Length int                      `json:"length"`
	Data   []map[string]interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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