Documentation ¶
Index ¶
- Variables
- func AESDecrypt(crypted, key []byte) []byte
- func AESEncrypt(origData, key []byte) []byte
- func BytesToString(b []byte) string
- func CheckNotExist(src string) bool
- func CheckPermission(src string) bool
- func EncodeMD5(value string) string
- func GetExt(fileName string) string
- func GetSize(f multipart.File) (int, error)
- func IsNotExistMkDir(src string) error
- func IsZero(i ...interface{}) bool
- func JSONMarshalToString(v interface{}) string
- func MD5Hash(b []byte) string
- func MD5HashString(s string) string
- func MkDir(src string) error
- func MustOpen(fileName, filePath string) (*os.File, error)
- func MustUUID() string
- func NewRecordID() string
- func NewTraceID() string
- func NewUUID() (string, error)
- func Open(name string, flag int, perm os.FileMode) (*os.File, error)
- func PKCS7Padding(origData []byte, blockSize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func SHA1Hash(b []byte) string
- func SHA1HashString(s string) string
- func StringToBytes(s string) (b []byte)
- func StructMapToStruct(s, ts interface{}) error
- type ObjectID
- 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) String() string
- func (s S) ToJSON(v interface{}) error
- func (s S) Uint() (uint, error)
- func (s S) Uint64() (uint64, error)
Constants ¶
This section is empty.
Variables ¶
var ( JSONMarshal = json.Marshal JSONUnmarshal = json.Unmarshal JSONMarshalIndent = json.MarshalIndent JSONNewDecoder = json.NewDecoder JSONNewEncoder = json.NewEncoder )
定义JSON操作
var ( YAMLMarshal = yaml.Marshal YAMLUnmarshal = yaml.Unmarshal YAMLNewDecoder = yaml.NewDecoder YAMLNewEncoder = yaml.NewEncoder )
定义YAML操作
var ErrInvalidHex = errors.New("the provided hex string is not a valid ObjectID")
ErrInvalidHex indicates that a hex string cannot be converted to an ObjectID.
Functions ¶
func AESEncrypt ¶
func BytesToString ¶
BytesToString converts byte slice to string without a memory allocation.
func CheckPermission ¶
CheckPermission check if the file has permission
func IsNotExistMkDir ¶
IsNotExistMkDir create a directory if it does not exist
func JSONMarshalToString ¶
func JSONMarshalToString(v interface{}) string
JSONMarshalToString JSON编码为字符串
func StringToBytes ¶
StringToBytes converts string to byte slice without a memory allocation.
Types ¶
type ObjectID ¶
type ObjectID [12]byte
ObjectID is the BSON ObjectID type.
var NilObjectID ObjectID
NilObjectID is the zero value for ObjectID.
func NewObjectIDFromTimestamp ¶
NewObjectIDFromTimestamp generates a new ObjectID based on the given time.
func ObjectIDFromHex ¶
ObjectIDFromHex creates a new ObjectID from a hex string. It returns an error if the hex string is not a valid ObjectID.
func (ObjectID) MarshalJSON ¶
MarshalJSON returns the ObjectID as a string
func (*ObjectID) UnmarshalJSON ¶
UnmarshalJSON populates the byte slice with the ObjectID. If the byte slice is 64 bytes long, it will be populated with the hex representation of the ObjectID. If the byte slice is twelve bytes long, it will be populated with the BSON representation of the ObjectID. Otherwise, it will return an error.
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,如果出现错误则使用默认值