u

package module
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 29 Imported by: 49

README

utility

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GlobalRand1 = rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
View Source
var GlobalRand2 = rand.New(rand.NewSource(int64(time.Now().Unix())))

Functions

func AddFileToMemory added in v1.7.4

func AddFileToMemory(memFile MemFile)

func AppendInt

func AppendInt(buf []byte, u uint64) []byte

func AppendUniqueString added in v0.1.17

func AppendUniqueString(to []string, from string) []string

func AppendUniqueStrings added in v0.1.17

func AppendUniqueStrings(to []string, from []string) []string

func BBlack

func BBlack(s interface{}, attribs ...AttribCode) string

func BBlue

func BBlue(s interface{}, attribs ...AttribCode) string

func BCyan

func BCyan(s interface{}, attribs ...AttribCode) string

func BGreen

func BGreen(s interface{}, attribs ...AttribCode) string

func BMagenta

func BMagenta(s interface{}, attribs ...AttribCode) string

func BRed

func BRed(s interface{}, attribs ...AttribCode) string

func BWhite

func BWhite(s interface{}, attribs ...AttribCode) string

func BYellow

func BYellow(s interface{}, attribs ...AttribCode) string

func Base64 added in v0.5.40

func Base64(data []byte) string

func Base64String added in v0.5.40

func Base64String(data string) string

func Black

func Black(s interface{}, attribs ...AttribCode) string

func Blue

func Blue(s interface{}, attribs ...AttribCode) string

func Bool

func Bool(value interface{}) bool

func Bytes

func Bytes(value interface{}) []byte

func CheckPath added in v0.0.8

func CheckPath(filename string)

func Color

func Color(s interface{}, textColor TextColor, bgColor BgColor, attribs ...AttribCode) string

func Convert added in v0.1.9

func Convert(from, to interface{})

func CopyFile added in v0.5.40

func CopyFile(from, to string) error

func CopyToFile added in v0.5.40

func CopyToFile(from io.Reader, to string) error

func Cyan

func Cyan(s interface{}, attribs ...AttribCode) string

func DecodeInt

func DecodeInt(buf []byte) uint64

func DecryptAes

func DecryptAes(crypted string, key []byte, iv []byte) (out string)

func DecryptAesBytes added in v0.1.17

func DecryptAesBytes(cryptedBytes []byte, key []byte, iv []byte) (out []byte, outErr error)

func Dim added in v0.0.4

func Dim(s interface{}) string

func Duration added in v0.1.17

func Duration(value string) time.Duration

func EncodeInt

func EncodeInt(u uint64) []byte

func EncryptAes

func EncryptAes(origData string, key []byte, iv []byte) (out string)

func EncryptAesBytes added in v0.1.17

func EncryptAesBytes(origData []byte, key []byte, iv []byte) (out []byte, outErr error)

func FileExists added in v0.0.8

func FileExists(filename string) bool

func FillInt added in v0.1.17

func FillInt(buf []byte, length int) []byte

func FinalSet added in v1.7.1

func FinalSet(from, to reflect.Value)

func FinalType added in v0.1.9

func FinalType(v reflect.Value) reflect.Type

func FinalValue added in v0.1.9

func FinalValue(v reflect.Value) reflect.Value

func FixJsonBytes added in v0.5.40

func FixJsonBytes(b []byte) []byte

修复Golang中Json默认处理HTML转义 < > & 的问题

func FixNilValue added in v0.1.9

func FixNilValue(v reflect.Value)

func FixPath added in v0.1.17

func FixPath(path string) string

func FixPtr added in v0.5.33

func FixPtr(value interface{}) interface{}

func FixUpperCase

func FixUpperCase(data []byte, excludesKeys []string)

func FixedJson added in v0.5.40

func FixedJson(value interface{}) string

func FixedJsonP added in v0.5.40

func FixedJsonP(value interface{}) string

func Float

func Float(value interface{}) float32

func Float64

func Float64(value interface{}) float64

func Floats

func Floats(value interface{}) []float64

func GenECDSA256Key added in v0.5.48

func GenECDSA256Key() (privateKey string, publicKey string, err error)

func GenECDSA384Key added in v0.5.48

func GenECDSA384Key() (privateKey string, publicKey string, err error)

func GenECDSA521Key added in v0.5.48

func GenECDSA521Key() (privateKey string, publicKey string, err error)

func GenECDSAKey added in v0.5.48

func GenECDSAKey(curve elliptic.Curve) (privateKey string, publicKey string, err error)

func GetAbsFilename added in v1.7.5

func GetAbsFilename(filename string) string

func GetLowerName added in v0.1.9

func GetLowerName(s string) string

func GetUpperName added in v0.1.9

func GetUpperName(s string) string

func Green

func Green(s interface{}, attribs ...AttribCode) string

func Gunzip added in v1.7.4

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

func GunzipN added in v1.7.4

func GunzipN(data []byte) []byte

func Gzip added in v1.7.4

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

func GzipN added in v1.7.4

func GzipN(data []byte) []byte

func Id10 added in v0.1.17

func Id10() string

约81亿亿

func Id12 added in v0.1.17

func Id12() string

约312303亿亿

func Id6 added in v0.1.17

func Id6() string

约 550亿

func Id8 added in v0.1.17

func Id8() string

约 2113536亿

func If

func If(i bool, a, b interface{}) interface{}

func In added in v0.1.8

func In(arr []interface{}, s interface{}) bool

func Int

func Int(value interface{}) int

func Int64

func Int64(value interface{}) int64

func Ints

func Ints(value interface{}) []int64

func Italic added in v0.0.4

func Italic(s interface{}) string

func JoinArgs added in v0.5.30

func JoinArgs(arr []string, sep string) string

func Json added in v0.1.6

func Json(value interface{}) string

func JsonBytes added in v0.5.40

func JsonBytes(value interface{}) []byte

func JsonBytesP added in v0.5.40

func JsonBytesP(value interface{}) []byte

func JsonP added in v0.1.6

func JsonP(value interface{}) string

func Load added in v0.0.8

func Load(filename string, to interface{}) error

func LoadFileToMemory added in v1.7.4

func LoadFileToMemory(filename string)

func LoadFileToMemoryWithCompress added in v1.7.4

func LoadFileToMemoryWithCompress(filename string)

func LoadFilesToMemoryFromB64 added in v1.7.4

func LoadFilesToMemoryFromB64(b64File *MemFileB64)

func LoadFilesToMemoryFromB64KeepGzip added in v1.7.4

func LoadFilesToMemoryFromB64KeepGzip(b64File *MemFileB64)

func LoadFilesToMemoryFromJson added in v1.7.4

func LoadFilesToMemoryFromJson(jsonFiles string)

func LoadJson added in v0.1.13

func LoadJson(filename string, to interface{}) error

func LoadX added in v0.5.30

func LoadX(filename string, to interface{}) error

func LoadYaml added in v0.1.13

func LoadYaml(filename string, to interface{}) error

func MD5 added in v0.1.17

func MD5(data []byte) []byte

func MD5Base64 added in v0.1.17

func MD5Base64(data string) string

func MD5String added in v0.1.17

func MD5String(data string) string

func Magenta

func Magenta(s interface{}, attribs ...AttribCode) string

func MakeECDSA256PrivateKey added in v0.5.48

func MakeECDSA256PrivateKey(privateKeyStr string) (priKey *ecdsa.PrivateKey, err error)

func MakeECDSA256PublicKey added in v0.5.48

func MakeECDSA256PublicKey(publicKeyStr string) (pubKey *ecdsa.PublicKey, err error)

func MakeECDSA384PrivateKey added in v0.5.48

func MakeECDSA384PrivateKey(privateKeyStr string) (priKey *ecdsa.PrivateKey, err error)

func MakeECDSA384PublicKey added in v0.5.48

func MakeECDSA384PublicKey(publicKeyStr string) (pubKey *ecdsa.PublicKey, err error)

func MakeECDSA521PrivateKey added in v0.5.48

func MakeECDSA521PrivateKey(privateKeyStr string) (priKey *ecdsa.PrivateKey, err error)

func MakeECDSA521PublicKey added in v0.5.48

func MakeECDSA521PublicKey(publicKeyStr string) (pubKey *ecdsa.PublicKey, err error)

func MakeECDSAPrivateKey added in v0.5.48

func MakeECDSAPrivateKey(privateKeyStr string, curve elliptic.Curve) (priKey *ecdsa.PrivateKey, err error)

func MakeECDSAPublicKey added in v0.5.48

func MakeECDSAPublicKey(publicKeyStr string, curve elliptic.Curve) (pubKey *ecdsa.PublicKey, err error)

func MakeExcludeUpperKeys added in v0.5.50

func MakeExcludeUpperKeys(data interface{}, prefix string) []string

func MakeToken added in v0.5.43

func MakeToken(size int) []byte

func NewIntEncoder

func NewIntEncoder(digits string, radix uint8) (*intEncoder, error)

func ParseInt added in v0.1.9

func ParseInt(s string) int64

func ParseUint added in v0.1.9

func ParseUint(s string) uint64

func ReadFile added in v0.0.8

func ReadFile(filename string) (string, error)

func ReadFileBytes added in v0.5.30

func ReadFileBytes(filename string) ([]byte, error)

func ReadFileBytesN added in v1.7.4

func ReadFileBytesN(filename string) []byte

func ReadFileLines added in v0.1.15

func ReadFileLines(filename string) ([]string, error)

func ReadFileLinesN added in v1.7.4

func ReadFileLinesN(filename string) []string

func ReadFileN added in v1.7.4

func ReadFileN(filename string) string

func RealValue added in v0.1.9

func RealValue(v reflect.Value) reflect.Value

func Red

func Red(s interface{}, attribs ...AttribCode) string

func RunCommand added in v0.0.8

func RunCommand(command string, args ...string) ([]string, error)

func Save added in v0.0.8

func Save(filename string, data interface{}) error

func SaveJson added in v0.1.13

func SaveJson(filename string, data interface{}) error

func SaveJsonP added in v0.1.17

func SaveJsonP(filename string, data interface{}) error

func SaveYaml added in v0.1.13

func SaveYaml(filename string, data interface{}) error

func SetValue added in v0.1.17

func SetValue(to, from reflect.Value)

func Sha1 added in v0.1.17

func Sha1(data []byte) []byte

func Sha1Base64 added in v0.1.17

func Sha1Base64(data string) string

func Sha1String added in v0.1.17

func Sha1String(data string) string

func Sha256 added in v0.1.17

func Sha256(data []byte) []byte

func Sha256Base64 added in v0.1.17

func Sha256Base64(data string) string

func Sha256String added in v0.1.17

func Sha256String(data string) string

func Sha512 added in v0.1.17

func Sha512(data []byte) []byte

func Sha512Base64 added in v0.1.17

func Sha512Base64(data string) string

func Sha512String added in v0.1.17

func Sha512String(data string) string

func ShortUniqueId added in v0.0.10

func ShortUniqueId() string

func SignECDSA added in v0.5.48

func SignECDSA(content []byte, priKey *ecdsa.PrivateKey) (signature string, err error)

func SplitArgs added in v0.5.30

func SplitArgs(s string) []string

func SplitTrim added in v0.1.12

func SplitTrim(s, sep string) []string

func SplitWithoutNone added in v0.1.17

func SplitWithoutNone(s, sep string) []string

func String

func String(value interface{}) string

func StringIf

func StringIf(i bool, a, b string) string

func StringIn added in v0.1.8

func StringIn(arr []string, s string) bool

func StringP added in v0.5.50

func StringP(value interface{}) string

func Strings

func Strings(value interface{}) []string

func Switch

func Switch(i uint, args ...interface{}) interface{}

func ToInterfaceArray added in v0.1.17

func ToInterfaceArray(in interface{}) []interface{}

func Uint added in v0.1.9

func Uint(value interface{}) uint

func Uint64 added in v0.1.9

func Uint64(value interface{}) uint64

func UnBase64 added in v0.5.40

func UnBase64(data string) []byte

func UnBase64String added in v0.5.40

func UnBase64String(data string) string

func UnJson added in v0.5.40

func UnJson(str string, value interface{}) interface{}

func UnJsonArr added in v0.5.40

func UnJsonArr(str string) []interface{}

func UnJsonBytes added in v0.5.40

func UnJsonBytes(data []byte, value interface{}) interface{}

func UnJsonMap added in v0.5.40

func UnJsonMap(str string) map[string]interface{}

func UnUrlBase64 added in v0.5.40

func UnUrlBase64(data string) []byte

func UnUrlBase64String added in v0.5.40

func UnUrlBase64String(data string) string

func UnYaml added in v0.5.40

func UnYaml(data string, value interface{}) interface{}

func UnYamlArr added in v0.5.40

func UnYamlArr(data string) []interface{}

func UnYamlMap added in v0.5.40

func UnYamlMap(data string) map[string]interface{}

func UniqueId

func UniqueId() string

func UrlBase64 added in v0.5.40

func UrlBase64(data []byte) string

func UrlBase64String added in v0.5.40

func UrlBase64String(data string) string

func ValueToString added in v0.1.10

func ValueToString(v reflect.Value) string

func VerifyECDSA added in v0.5.48

func VerifyECDSA(content []byte, signature string, pubKey *ecdsa.PublicKey) bool

func White

func White(s interface{}, attribs ...AttribCode) string

func WriteFile added in v0.1.15

func WriteFile(filename string, content string) error

func WriteFileBytes added in v0.5.30

func WriteFileBytes(filename string, content []byte) error

func Yaml added in v0.5.40

func Yaml(value interface{}) string

func Yellow

func Yellow(s interface{}, attribs ...AttribCode) string

Types

type Aes added in v0.5.40

type Aes struct {
	// contains filtered or unexported fields
}

func NewAes added in v0.5.40

func NewAes(key, iv []byte) *Aes

func (*Aes) DecryptBase64ToBytes added in v0.5.40

func (_this *Aes) DecryptBase64ToBytes(data string) []byte

func (*Aes) DecryptBase64ToString added in v0.5.40

func (_this *Aes) DecryptBase64ToString(data string) string

func (*Aes) DecryptBytes added in v0.5.40

func (_this *Aes) DecryptBytes(data []byte) (out []byte, outErr error)

func (*Aes) DecryptHexToBytes added in v0.5.40

func (_this *Aes) DecryptHexToBytes(data string) []byte

func (*Aes) DecryptHexToString added in v0.5.40

func (_this *Aes) DecryptHexToString(data string) string

func (*Aes) DecryptUrlBase64ToBytes added in v0.5.40

func (_this *Aes) DecryptUrlBase64ToBytes(data string) []byte

func (*Aes) DecryptUrlBase64ToString added in v0.5.40

func (_this *Aes) DecryptUrlBase64ToString(data string) string

func (*Aes) EncryptBytes added in v0.5.40

func (_this *Aes) EncryptBytes(data []byte) (out []byte, outErr error)

func (*Aes) EncryptBytesToBase64 added in v0.5.40

func (_this *Aes) EncryptBytesToBase64(data []byte) string

func (*Aes) EncryptBytesToHex added in v0.5.40

func (_this *Aes) EncryptBytesToHex(data []byte) string

func (*Aes) EncryptBytesToUrlBase64 added in v0.5.40

func (_this *Aes) EncryptBytesToUrlBase64(data []byte) string

func (*Aes) EncryptStringToBase64 added in v0.5.40

func (_this *Aes) EncryptStringToBase64(data string) string

func (*Aes) EncryptStringToHex added in v0.5.40

func (_this *Aes) EncryptStringToHex(data string) string

func (*Aes) EncryptStringToUrlBase64 added in v0.5.40

func (_this *Aes) EncryptStringToUrlBase64(data string) string

type AttribCode

type AttribCode int
const (
	AttrNone AttribCode = iota
	AttrBold
	AttrDim
	AttrItalic
	AttrUnderline
	AttrBlink
	AttrFastBlink
	AttrReverse
	AttrHidden
	AttrCrossedOut
)

type BgColor

type BgColor int
const (
	BgBlack BgColor = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
	BgNone BgColor = 0
)

type FileInfo added in v1.7.4

type FileInfo struct {
	Name     string
	FullName string
	IsDir    bool
	Size     int64
	ModTime  time.Time
}

func GetFileInfo added in v1.7.5

func GetFileInfo(filename string) *FileInfo

func ReadDir added in v1.7.4

func ReadDir(filename string) ([]FileInfo, error)

func ReadDirN added in v1.7.4

func ReadDirN(filename string) []FileInfo

type MemFile added in v1.7.4

type MemFile struct {
	Name string

	ModTime    time.Time
	IsDir      bool
	Compressed bool
	Size       int64
	Data       []byte
	// contains filtered or unexported fields
}

func ReadDirFromMemory added in v1.7.4

func ReadDirFromMemory(name string) []MemFile

func ReadFileFromMemory added in v1.7.4

func ReadFileFromMemory(name string) *MemFile

func (*MemFile) GetData added in v1.7.4

func (mf *MemFile) GetData() []byte

type MemFileB64 added in v1.7.4

type MemFileB64 struct {
	Name       string
	ModTime    time.Time
	IsDir      bool
	DataB64    string
	Compressed bool
	Size       int64
	Children   []MemFileB64
}

func LoadFileToB64 added in v1.7.4

func LoadFileToB64(filename string) *MemFileB64

type StructInfo added in v0.5.43

type StructInfo struct {
	Fields       []reflect.StructField
	Values       map[string]reflect.Value
	Methods      []reflect.Method
	MethodValues map[string]reflect.Value
}

func FlatStruct added in v0.5.43

func FlatStruct(data interface{}) *StructInfo

func FlatStructWithUnexported added in v0.5.43

func FlatStructWithUnexported(data interface{}) *StructInfo

type TextColor

type TextColor int
const (
	TextBlack TextColor = iota + 30
	TextRed
	TextGreen
	TextYellow
	TextBlue
	TextMagenta
	TextCyan
	TextWhite
	TextNone TextColor = 0
)

Jump to

Keyboard shortcuts

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