Documentation ¶
Index ¶
- Constants
- Variables
- func Abs(x int) int
- func AesDecrypt(cypted []byte, key []byte) (string, error)
- func AesDemo()
- func AesDemo2()
- func AesEncrypt(origData []byte, key []byte) ([]byte, error)
- func AnyToAny(src interface{}, des interface{}) error
- func AnyToAnyV2(src interface{}, des interface{}) error
- func Base64Dec(encodeString string) string
- func Base64DecUrl(encodeString string) string
- func Base64Enc(input []byte) string
- func Base64EncUrl(input []byte) string
- func Black(str string, modifier ...interface{}) string
- func Blue(str string, modifier ...interface{}) string
- func Brown(str string, modifier ...interface{}) string
- func CertInfo(certPath string, certBytes []byte) (*x509.Certificate, error)
- func CheckEmail(email string) error
- func CurrentUTCTime() string
- func Cyan(str string, modifier ...interface{}) string
- func DarkGray(str string, modifier ...interface{}) string
- func DeTxtByAes(pwd, PwdKey string) string
- func DecBase64ByAes(data string, keyText string) []byte
- func Decrypt3DES(src, private []byte) []byte
- func DecryptDES(src, private []byte) []byte
- func Difference(slice1, slice2 []string) []string
- func Dir() (string, error)
- func EnTxtByAes(pwdStr, PwdKey string) string
- func EncBase64ByAes(data string, keyText string) string
- func Encrypt3DES(src []byte, private []byte) []byte
- func EncryptDES(src []byte, private []byte) []byte
- func EnsureDirExist(name string) error
- func Expand(path string) (string, error)
- func FileExists(name string) bool
- func GetMapDefault(k, defaultValue interface{}, m map[interface{}]interface{}) interface{}
- func GetRandomString(length int) string
- func GetSrcZips(src string) ([]string, error)
- func GobAnyToAny(src interface{}, des interface{}) error
- func Green(str string, modifier ...interface{}) string
- func GzipCompressFile(srcPath, dstPath string) error
- func HashAndSalt(pwd []byte) string
- func In(haystack interface{}, needle interface{}) (bool, error)
- func InIntSliceMapKeyFunc(haystack []int) func(int) bool
- func InOfInt(obj int, arrayList []int) bool
- func InOfInt32(obj int32, arrayList []int32) bool
- func InOfInt64(obj int64, arrayList []int64) bool
- func InOfStr(str string, arrayList []string) bool
- func InOfType(obj interface{}, arrayList []interface{}, dataType string) bool
- func Intersect(slice1, slice2 []string) []string
- func IsDir(src string) (bool, error)
- func IsFileExist(filePath string) (bool, error)
- func IsZip(src string) (bool, error)
- func JSONMarshalToString(v interface{}) string
- func LightBlue(str string, modifier ...interface{}) string
- func LightCyan(str string, modifier ...interface{}) string
- func LightGray(str string, modifier ...interface{}) string
- func LightGreen(str string, modifier ...interface{}) string
- func LightPurple(str string, modifier ...interface{}) string
- func LightRed(str string, modifier ...interface{}) string
- func MD5Hash(b []byte) string
- func MD5HashString(s string) string
- func MD5HashString16(data string) string
- func MapWriteXlsx(sheet string, records interface{}) (*excelize.File, error)
- func Marshal(v interface{}) (string, error)
- func MsgpackAnyToAny(src interface{}, des interface{}) error
- func PKCS7Padding(ciphertext []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) ([]byte, error)
- func Pop(haystack interface{}, needle interface{}) (bool, error)
- func PrettyJson(data interface{}) (string, error)
- func Purple(str string, modifier ...interface{}) string
- func RandString(len int) string
- func Red(str string, modifier ...interface{}) string
- func Request(url, method string, param interface{}, headers []map[string]string, ...) ([]byte, error)
- func Reset()
- func SHA1Hash(b []byte) string
- func SHA1HashString(s string) string
- func SHA256Hash(b []byte) string
- func SHA256HashString(s string) string
- func SortInIntSlice(haystack []int, needle int) bool
- func String(b []byte) string
- func StringWithoutZero(b []byte) string
- func StructWriteXlsx(sheet string, records interface{}) *excelize.File
- func Sum(i []int) int
- func TestAll()
- func UnZipCompress(src, dst string) error
- func Union(slice1, slice2 []string) []string
- func Unmarshal(s string, v interface{}) error
- func UrlEncode(param map[string]string) string
- func ValidateSaltPasswords(hashedPwd string, plainPwd []byte) bool
- func White(str string, modifier ...interface{}) string
- func Yellow(str string, modifier ...interface{}) string
- func ZipCompress(srcDir, dstZipPath string) error
- type Alignment
- type Border
- type Fill
- type Font
- type Fruit
- type Hash
- type IHash
- type Protection
- type ResponseExec
- type S
- func (s S) Bool() (bool, error)
- func (s S) Bytes() []byte
- func (s S) DefaultBool(defaultVal bool) bool
- func (s S) DefaultFloat32(defaultVal float32) float32
- func (s S) DefaultFloat64(defaultVal float64) float64
- func (s S) DefaultInt(defaultVal int) int
- func (s S) DefaultInt64(defaultVal int64) int64
- func (s S) DefaultUint(defaultVal int) int
- func (s S) DefaultUint64(defaultVal uint64) uint64
- func (s S) Float32() (float32, error)
- func (s S) Float64() (float64, error)
- func (s S) Int() (int, error)
- func (s S) Int64() (int64, error)
- func (s S) JsonToString(v interface{}) error
- func (s S) String() string
- func (s S) Uint() (int, error)
- func (s S) Uint64() (uint64, error)
- type Style
- type UUID
Constants ¶
const (
ExtZip = ".zip"
)
Variables ¶
var ( Json = jsoniter.ConfigCompatibleWithStandardLibrary JSONMarshal = Json.Marshal JSONUnmarshal = Json.Unmarshal JSONMarshalIndent = Json.MarshalIndent JSONNewDecoder = Json.NewDecoder JSONNewEncoder = Json.NewEncoder )
定义JSON操作
var DefaultTxtKey = "Airkbook1qaz*WSP"
16,24,32位字符串的话,分别对应AES-128,AES-192,AES-256 加密方法 key不能泄露 var PwdKey = []byte("DIS**#KKKDJJSKDI")
var DisableCache bool
DisableCache will disable caching of the home directory. Caching is enabled by default.
Functions ¶
func AesDecrypt ¶ added in v1.10.2
AesDecrypt 实现解密
func AesEncrypt ¶ added in v1.10.2
AesEncrypt 实现加密
func AnyToAnyV2 ¶ added in v1.10.8
func AnyToAnyV2(src interface{}, des interface{}) error
func CertInfo ¶ added in v1.0.8
func CertInfo(certPath string, certBytes []byte) (*x509.Certificate, error)
CertInfo "test.pem"
func CurrentUTCTime ¶
func CurrentUTCTime() string
func DeTxtByAes ¶ added in v1.10.2
DeTxtByAes 解密base64 aes
func DecBase64ByAes ¶ added in v1.10.2
DecBase64ByAes Aes + base64 解密
func Dir ¶
Dir returns the home directory for the executing user.
This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.
func EnTxtByAes ¶ added in v1.10.2
EnTxtByAes 加密base64
func EncBase64ByAes ¶ added in v1.10.2
EncBase64ByAes Aes加密 后 base64 再加密
func Encrypt3DES ¶
Encrypt3DES 使用des进行对称加密 length 24
func EncryptDES ¶
EncryptDES 使用des进行对称加密 length 8
func EnsureDirExist ¶
func Expand ¶
Expand expands the path to include the home directory if the path is prefixed with `~`. If it isn't prefixed with `~`, the path is returned as-is.
func FileExists ¶
func GetMapDefault ¶
func GetMapDefault(k, defaultValue interface{}, m map[interface{}]interface{}) interface{}
func GetRandomString ¶
func GetSrcZips ¶ added in v1.0.8
func GobAnyToAny ¶ added in v1.10.8
func GobAnyToAny(src interface{}, des interface{}) error
func GzipCompressFile ¶
func HashAndSalt ¶ added in v1.0.8
HashAndSalt Hash & Salt 用户的密码
func InIntSliceMapKeyFunc ¶
func IsFileExist ¶ added in v1.0.8
func JSONMarshalToString ¶
func JSONMarshalToString(v interface{}) string
JSONMarshalToString JSON编码为字符串
func MapWriteXlsx ¶ added in v1.10.8
func MsgpackAnyToAny ¶ added in v1.10.8
func MsgpackAnyToAny(src interface{}, des interface{}) error
func PKCS7Padding ¶ added in v1.10.2
PKCS7Padding PKCS7 填充模式 填充最后一个分组的函数 ciphertext - 原始数据 blockSize - 每个分组的数据长度
func PKCS7UnPadding ¶ added in v1.10.2
PKCS7UnPadding 填充的反向操作,删除填充字符串
func PrettyJson ¶
func RandString ¶
func Reset ¶
func Reset()
Reset clears the cache, forcing the next call to Dir to re-detect the home directory. This generally never has to be called, but can be useful in tests if you're modifying the home directory via the HOME env var or something.
func StringWithoutZero ¶ added in v1.10.8
StringWithoutZero 将 `[]byte` 转换为 `string`
func StructWriteXlsx ¶ added in v1.10.8
func StructWriteXlsx(sheet string, records interface{}) *excelize.File
func ValidateSaltPasswords ¶ added in v1.0.8
ValidateSaltPasswords 验证密码 参数 hashedPwd: Hash & Salt 用户的密码,plainPwd: 明文密码
func ZipCompress ¶ added in v1.10.8
ZipCompress zip压缩
Types ¶
type Alignment ¶ added in v1.10.8
type Alignment struct { Horizontal string `json:"horizontal"` // 水平对齐方式 Indent int `json:"indent"` // 缩进 只要设置了值,就变成了左对齐 JustifyLastLine bool `json:"justify_last_line"` // 两端分散对齐,只有在水平对齐选择 distributed 时起作用 ReadingOrder uint64 `json:"reading_order"` // 文字方向 不知道值范围和具体的含义 RelativeIndent int `json:"relative_indent"` // 不知道具体的含义 ShrinkToFit bool `json:"shrink_to_fit"` // 缩小字体填充 TextRotation int `json:"text_rotation"` // 文本旋转 Vertical string `json:"vertical"` // 垂直对齐 WrapText bool `json:"wrap_text"` // 自动换行 }
Alignment 对齐
type Border ¶ added in v1.10.8
type Border struct { Type string `json:"type"` Color string `json:"color"` Style int `json:"style"` }
Border 边框
type Fill ¶ added in v1.10.8
type Fill struct { Type string `json:"type"` Pattern int `json:"pattern"` Color []string `json:"color"` Shading int `json:"shading"` }
Fill 填充
type Font ¶ added in v1.10.8
type Font struct { Bold bool `json:"bold"` // 是否加粗 Italic bool `json:"italic"` // 是否倾斜 Underline string `json:"underline"` // single double Family string `json:"family"` // 字体样式 Size float64 `json:"size"` // 字体大小 Strike bool `json:"strike"` // 删除线 Color string `json:"color"` // 字体颜色 }
Font 字体
type Protection ¶ added in v1.10.8
Protection 保护
type ResponseExec ¶ added in v1.0.8
type S ¶
type S string
S 字符串类型转换
func (S) DefaultBool ¶
DefaultBool 转换为bool,如果出现错误则使用默认值
func (S) DefaultFloat32 ¶
DefaultFloat32 转换为float32,如果出现错误则使用默认值
func (S) DefaultFloat64 ¶
DefaultFloat64 转换为float64,如果出现错误则使用默认值
func (S) DefaultInt64 ¶
DefaultInt64 转换为int64,如果出现错误则使用默认值
func (S) DefaultUint64 ¶
DefaultUint64 转换为uint64,如果出现错误则使用默认值
func (S) JsonToString ¶
type Style ¶ added in v1.10.8
type Style struct { Border []Border `json:"border"` Fill Fill `json:"fill"` Font *Font `json:"font"` Alignment *Alignment `json:"alignment"` Protection *Protection `json:"protection"` NumFmt int `json:"number_format"` DecimalPlaces int `json:"decimal_places"` CustomNumFmt *string `json:"custom_number_format"` Lang string `json:"lang"` NegRed bool `json:"negred"` }
type UUID ¶
type UUID [16]byte
A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC 4122.
var Nil UUID
Nil empty UUID, all zeros
func NewHash ¶
NewHash returns a new UUID derived from the hash of space concatenated with data generated by h. The hash should be at least 16 byte in length. The first 16 bytes of the hash are used to form the UUID. The version of the UUID will be the lower 4 bits of version.
func NewMD5 ¶
NewMD5 returns a new MD5 (Version 3) UUID based on the supplied name space and data. It is the same as calling:
NewHash(md5.New(), space, data, 3)
func NewRandom ¶
NewRandom returns a Random (Version 4) UUID.
The strength of the UUIDs is based on the strength of the crypto/rand package.
A note about uniqueness derived from the UUID Wikipedia entry:
Randomly generated UUIDs have 122 random bits. One's annual risk of being hit by a meteorite is estimated to be one chance in 17 billion, that means the probability is about 0.00000000006 (6 × 10−11), equivalent to the odds of creating a few tens of trillions of UUIDs in a year and having one duplicate.
func NewSHA1 ¶
NewSHA1 returns a new SHA1 (Version 5) UUID based on the supplied name space and data. It is the same as calling:
NewHash(sha1.New(), space, data, 5)