Documentation ¶
Index ¶
- Constants
- Variables
- func CurrentTimeStamp() int64
- func CurrentTimeStampMS() int64
- func CurrentTimeStampNS() int64
- func CurrentTimeStampString() string
- func GenerateNonceStr() string
- func GenerateRandomString(size int, kind ...RandomKind) string
- func GenerateRandomString2(size int, kind int) []byte
- func GenerateSignature(p Map, key string, fn SignFunc) string
- func GenerateSignatureWithIgnore(p Map, key string, ignore []string) string
- func GenerateUUID() string
- func HmacSha256(data []byte, key string) string
- func In(source []string, v string) bool
- func InterfaceToMap(v interface{}, m *Map) error
- func MakeSignHMACSHA256(data, key string) string
- func MakeSignMD5(data, key string) string
- func MapToString(data Map, ignore []string) string
- func MapToXML(m Map) ([]byte, error)
- func ParseInt(v interface{}) (int64, bool)
- func ParseNumber(v interface{}) (float64, bool)
- func ParseString(v interface{}) (string, bool)
- func SHA1(s string) string
- func Time(t ...time.Time) string
- func ToURLParams(data Map, ignore []string) string
- func ValidateSign(maps Map, key string) bool
- type CDATA
- type Map
- func (m Map) Append(p Map) Map
- func (m Map) Check(s ...string) int
- func (m Map) Clone() Map
- func (m Map) Delete(key string) bool
- func (m Map) DeletePath(keys []string) bool
- func (m Map) Expect(keys []string) Map
- func (m Map) Get(key string) interface{}
- func (m Map) GetArray(s string) []interface{}
- func (m Map) GetArrayD(s string, d []interface{}) []interface{}
- func (m Map) GetBool(s string) bool
- func (m Map) GetBoolD(s string, b bool) bool
- func (m Map) GetBytes(s string) []byte
- func (m Map) GetD(s string, d interface{}) interface{}
- func (m Map) GetInt64(s string) (int64, bool)
- func (m Map) GetInt64D(s string, d int64) int64
- func (m Map) GetMap(s string) Map
- func (m Map) GetMapArray(s string) []Map
- func (m Map) GetMapArrayD(s string, d []Map) []Map
- func (m Map) GetMapD(s string, d Map) Map
- func (m Map) GetNumber(s string) (float64, bool)
- func (m Map) GetNumberD(s string, d float64) float64
- func (m Map) GetPath(keys []string) interface{}
- func (m Map) GetString(s string) string
- func (m Map) GetStringD(s string, d string) string
- func (m Map) Has(key string) bool
- func (m Map) HasPath(keys []string) bool
- func (m Map) Join(s Map) Map
- func (m Map) Map() map[string]interface{}
- func (m Map) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (m Map) Only(keys []string) Map
- func (m Map) ParseJSON(b []byte) Map
- func (m Map) ParseXML(b []byte)
- func (m Map) Range(f func(key string, value interface{}) bool)
- func (m Map) ReplaceJoin(s Map) Map
- func (m Map) Set(key string, v interface{}) Map
- func (m Map) SetGet(s string, v Map) Map
- func (m Map) SetHas(s string, v interface{}) Map
- func (m Map) SetNil(s string, v interface{}) Map
- func (m Map) SetPath(keys []string, v interface{}) Map
- func (m Map) SortKeys() []string
- func (m Map) String() string
- func (m Map) ToJSON() []byte
- func (m Map) ToXML() []byte
- func (m Map) URLEncode() string
- func (m Map) URLToSHA1() string
- func (m Map) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- type RandomKind
- type SignFunc
- type String
- type StringAble
Constants ¶
const CustomHeader = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>`
CustomHeader xml header
const FieldLimit = "limit"
FieldLimit ...
const FieldSign = "sign"
FieldSign ...
const FieldSignType = "sign_type"
FieldSignType ...
const HMACSHA256 = "HMAC-SHA256"
HMACSHA256 定义:HMAC-SHA256
const MD5 = "MD5"
MD5 定义:MD5
Variables ¶
var ( ErrorSignType = errors.New("sign type error") ErrorParameter = errors.New("JsonApiParameters() check error") ErrorToken = errors.New("EditAddressParameters() token is nil") )
error types
var ErrNilMap = errors.New("nil map")
ErrNilMap ...
var ( RandomString = map[RandomKind]string{ RandomNum: "0123456789", RandomLower: "abcdefghijklmnopqrstuvwxyz", RandomUpper: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", RandomLowerNum: "0123456789abcdefghijklmnopqrstuvwxyz", RandomUpperNum: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", RandomAll: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", } )
RandomString defines
Functions ¶
func CurrentTimeStampMS ¶
func CurrentTimeStampMS() int64
CurrentTimeStampMS get current time with millisecond
func CurrentTimeStampNS ¶
func CurrentTimeStampNS() int64
CurrentTimeStampNS get current time with nanoseconds
func CurrentTimeStampString ¶
func CurrentTimeStampString() string
CurrentTimeStampString get current time to string
func GenerateRandomString ¶
func GenerateRandomString(size int, kind ...RandomKind) string
GenerateRandomString 随机字符串
func GenerateRandomString2 ¶
GenerateRandomString2 随机字符串
func GenerateSignature ¶ added in v1.1.2
GenerateSignature make sign from map data
func GenerateSignatureWithIgnore ¶ added in v1.1.2
GenerateSignatureWithIgnore ...
func HmacSha256 ¶ added in v1.1.4
func InterfaceToMap ¶ added in v1.1.4
func MakeSignHMACSHA256 ¶ added in v1.1.2
MakeSignHMACSHA256 make sign with hmac-sha256
func MakeSignMD5 ¶ added in v1.1.2
MakeSignMD5 make sign with md5
func ParseNumber ¶
ParseNumber parse interface to number
func ParseString ¶ added in v1.0.1
ParseString parse interface to string
func ValidateSign ¶ added in v1.1.2
ValidateSign check the sign validate
Types ¶
type Map ¶
type Map map[string]interface{}
Map Map
func (Map) Check ¶ added in v1.0.1
Check check all input keys return -1 if all is exist return index when not found
func (Map) GetMapArray ¶ added in v1.0.1
GetMapArray get map from map with out default
func (Map) GetMapArrayD ¶ added in v1.0.1
GetMapArrayD get map from map with default
func (Map) GetNumberD ¶
GetNumberD get float64 from map with default
func (Map) GetPath ¶ added in v1.0.1
GetPath returns the element in the tree indicated by 'keys'. If keys is of length zero, the current tree is returned.
func (Map) GetStringD ¶
GetStringD get string from map with default
func (Map) HasPath ¶ added in v1.0.1
HasPath returns true if the given path of keys exists, false otherwise.
func (Map) MarshalXML ¶ added in v1.1.1
MarshalXML ...
func (Map) ReplaceJoin ¶
ReplaceJoin insert map s to m with replace
func (Map) SetPath ¶ added in v1.0.1
SetPath is the same as SetPath, but allows you to provide comment information to the key, that will be reused by Marshal().
func (Map) UnmarshalXML ¶ added in v1.1.1
UnmarshalXML ...
type RandomKind ¶
type RandomKind int
RandomKind RandomKind
const ( RandomNum RandomKind = iota // 纯数字 RandomLower // 小写字母 RandomUpper // 大写字母 RandomLowerNum // 数字、小写字母 RandomUpperNum // 数字、大写字母 RandomAll // 数字、大小写字母 )
random kinds