Documentation
¶
Overview ¶
提供一些实用函数
Index ¶
- Variables
- func AESDecryptData(cipherText []byte, aesKey []byte, iv []byte) (rawData []byte, err error)
- func AESDecryptMsg(ciphertext []byte, aesKey []byte) (random, rawXMLMsg, appId []byte, err error)
- func AESEncryptMsg(random, rawXMLMsg []byte, appId string, aesKey []byte) (ciphertext []byte)
- func BoolPtr(v bool) *bool
- func DecodeXMLToMap(r io.Reader) (m map[string]string, err error)
- func EncodeXMLFromMap(w io.Writer, m map[string]string, rootname string) (err error)
- func Float32Ptr(v float32) *float32
- func Float64Ptr(v float64) *float64
- func GetStringsBuilder() *strings.Builder
- func GetUrlValues() url.Values
- func HttpResponseWriter(w io.Writer) http.ResponseWriter
- func Int32Ptr(v int32) *int32
- func Int64Ptr(v int64) *int64
- func IntPtr(v int) *int
- func MsgSign(token, timestamp, nonce, encryptedMsg string) (signature string)
- func NonceStr() string
- func PutStringsBuilder(b *strings.Builder)
- func PutUrlValues(values url.Values)
- func SecureCompare(given, actual []byte) bool
- func SecureCompareString(given, actual string) bool
- func Sign(token, timestamp, nonce string) (signature string)
- func StringPtr(v string) *string
- func StringsJoin(strs ...string) string
- func ToLower(s string) string
- func Uint32Ptr(v uint32) *uint32
- func Uint64Ptr(v uint64) *uint64
- func WXVersion(userAgent string) (x, y, z, w int, err error)
- type Int64
- type MoneyFloat
- type Uint64
Constants ¶
This section is empty.
Variables ¶
var BeijingLocation = time.FixedZone("Asia/Shanghai", 8*60*60)
var DefaultHttpClient *http.Client
var DefaultMediaHttpClient *http.Client
Functions ¶
func AESDecryptData ¶
func AESDecryptMsg ¶
ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId]
func AESEncryptMsg ¶
ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId]
func BoolPtr ¶
Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.
func DecodeXMLToMap ¶
DecodeXMLToMap decodes xml reading from io.Reader and returns the first-level sub-node key-value set, if the first-level sub-node contains child nodes, skip it.
func EncodeXMLFromMap ¶
EncodeXMLFromMap encodes map[string]string to io.Writer with xml format.
NOTE: This function requires the rootname argument and the keys of m (type map[string]string) argument are legitimate xml name string that does not contain the required escape character!
func Float32Ptr ¶
Float32 is a helper routine that allocates a new float32 value to store v and returns a pointer to it.
func Float64Ptr ¶
Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.
func GetStringsBuilder ¶
func GetUrlValues ¶
func HttpResponseWriter ¶
func HttpResponseWriter(w io.Writer) http.ResponseWriter
将 io.Writer 从语义上实现 http.ResponseWriter.
func Int32Ptr ¶
Int32 is a helper routine that allocates a new int32 value to store v and returns a pointer to it.
func Int64Ptr ¶
Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.
func IntPtr ¶
Int is a helper routine that allocates a new int value to store v and returns a pointer to it.
func PutStringsBuilder ¶
func PutUrlValues ¶
func SecureCompare ¶
func SecureCompareString ¶
func StringPtr ¶
String is a helper routine that allocates a new string value to store v and returns a pointer to it.
func StringsJoin ¶
func Uint32Ptr ¶
Uint32 is a helper routine that allocates a new uint32 value to store v and returns a pointer to it.
Types ¶
type Int64 ¶
type Int64 int64
Int64 support string quoted number in json
func (*Int64) UnmarshalJSON ¶
UnmarshalJSON implement json Unmarshal interface
type MoneyFloat ¶
type MoneyFloat float64
MoneyFloat support string quoted number in json
func (MoneyFloat) Float64 ¶
func (f64 MoneyFloat) Float64() float64
func (*MoneyFloat) UnmarshalJSON ¶
func (f64 *MoneyFloat) UnmarshalJSON(b []byte) (err error)
UnmarshalJSON implement json Unmarshal interface