utils

package
v0.0.0-...-881c24d Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     = errors.New("token is expired")
	TokenNotValidYet = errors.New("token not active yet")
	TokenMalformed   = errors.New("that's not even a token")
	TokenInvalid     = errors.New("couldn't handle this token")
)

Functions

func CheckNetworkCableConn

func CheckNetworkCableConn(deviceName string) bool

func Cmd

func Cmd(cmd string) (string, error)

func Contain

func Contain(a []interface{}, e interface{}) bool

func ContainEx

func ContainEx(a interface{}, f func(predicate interface{}) bool) bool

func CreatDir

func CreatDir(dirPath string) error

func GetDiskFreePercent

func GetDiskFreePercent() (string, error)

func GetDiskFreeSize

func GetDiskFreeSize() (uint64, error)

获取磁盘可用大小(KB)

func GetDiskTotalSize

func GetDiskTotalSize() (uint64, error)

获取磁盘总大小(KB)

func GetDiskUsedSize

func GetDiskUsedSize() (uint64, error)

获取磁盘已用大小(KB)

func GetIni

func GetIni(section, key string) string

func GetPrevDir

func GetPrevDir(dirPath string) string

func GetSizeOfDir

func GetSizeOfDir(dirPath string) (int64, error)

获取指定目录大小(KB)

func InSlice

func InSlice(ss []string, s string) bool

func IsPathExist

func IsPathExist(filePath string) bool

func MD5

func MD5(v string) string

func RandStr

func RandStr(n int) string

func ReadAll

func ReadAll(path string) ([]byte, error)

func RemoveAll

func RemoveAll(dirPath string) error

func RemoveFile

func RemoveFile(filePath string) error

func SetIni

func SetIni(section, key, val string) error

func SuitableDisplaySize

func SuitableDisplaySize(size int64) string

func Unzip

func Unzip(zipFile string, destDir string) error

func WriteAll

func WriteAll(path string, data []byte) error

func Zip

func Zip(srcFile string, destZip string) error

Types

type CustomClaims

type CustomClaims struct {
	Username string
	jwt.StandardClaims
}

type JWT

type JWT struct {
	SigningKey []byte
}

func NewJWT

func NewJWT() *JWT

func (*JWT) CreateToken

func (j *JWT) CreateToken(claims CustomClaims) string

func (*JWT) ParseToken

func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)

type Response

type Response struct {
	Code int         `json:"code"`
	Desc string      `json:"desc"`
	Data interface{} `json:"data"`
}

func (Response) Failure

func (r Response) Failure() Response

func (Response) Success

func (r Response) Success(data interface{}) Response

func (Response) WithDesc

func (r Response) WithDesc(desc string) Response

Jump to

Keyboard shortcuts

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