Documentation ¶
Index ¶
- Variables
- func Abs(x int) int
- func AnyToAny(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 CheckEmail(email string) error
- func CurrentUTCTime() string
- func Cyan(str string, modifier ...interface{}) string
- func DarkGray(str string, modifier ...interface{}) string
- func Decrypt3DES(src, private []byte) []byte
- func DecryptAES(src, private []byte) []byte
- func DecryptDES(src, private []byte) []byte
- func Difference(slice1, slice2 []string) []string
- func Dir() (string, error)
- func Encrypt3DES(src []byte, private []byte) []byte
- func EncryptAES(src, 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 Green(str string, modifier ...interface{}) string
- func GzipCompressFile(srcPath, dstPath string) error
- 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 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 Marshal(v interface{}) (string, 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 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 Sum(i []int) int
- func TestAll()
- func Union(slice1, slice2 []string) []string
- func Unmarshal(s string, v interface{}) error
- func White(str string, modifier ...interface{}) string
- func Yellow(str string, modifier ...interface{}) string
- type Hash
- type IHash
- 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 uint) uint
- 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() (uint, error)
- func (s S) Uint64() (uint64, error)
- type UUID
Constants ¶
This section is empty.
Variables ¶
var ( JSONMarshal = json.Marshal JSONUnmarshal = json.Unmarshal JSONMarshalIndent = json.MarshalIndent JSONNewDecoder = json.NewDecoder JSONNewEncoder = json.NewEncoder )
定义JSON操作
var DisableCache bool
DisableCache will disable caching of the home directory. Caching is enabled by default.
Functions ¶
func CurrentUTCTime ¶
func CurrentUTCTime() string
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 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 GzipCompressFile ¶
func InIntSliceMapKeyFunc ¶
func JSONMarshalToString ¶
func JSONMarshalToString(v interface{}) string
JSONMarshalToString JSON编码为字符串
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.
Types ¶
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) DefaultUint ¶
DefaultUint 转换为uint,如果出现错误则使用默认值
func (S) DefaultUint64 ¶
DefaultUint64 转换为uint64,如果出现错误则使用默认值
func (S) JsonToString ¶
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)