Documentation ¶
Overview ¶
辅助工具层
Index ¶
- Constants
- Variables
- func AesDecryptCBC(encrypted []byte, key []byte) (decrypted []byte)
- func AesEncryptCBC(origData []byte, key []byte) (encrypted []byte)
- func Bytes2str(b []byte) string
- func BytesToStr(b []byte) string
- func CheckFileIsExist(filename string) bool
- func CheckNotNil(r *http.Request, args ...string) error
- func CheckParam(hr *http.Request, args ...string) string
- func CheckRemoteIP(r *http.Request, ips ...string) bool
- func ClientIP(r *http.Request) string
- func ClientPublicIP(r *http.Request) string
- func CreateAnyTypeSlice(slice interface{}) ([]interface{}, bool)
- func CtxClientIP(ctx *fasthttp.RequestCtx) string
- func CtxFormIntDefault(ctx *fiber.Ctx, key string, def int) int
- func CtxGetURL(URL string) ([]byte, error)
- func CtxGetURLReceiveJSON(URL string, params url.Values, receive interface{}) error
- func CtxGetValueURL(URL string, params url.Values) ([]byte, error)
- func DoURL(method, url string, body []byte) ([]byte, error)
- func ECBDecrypt(crypted []byte, keyStr string) ([]byte, error)
- func ECBEncrypt(srcStr, keyStr string) ([]byte, error)
- func FilterMysqlNilErr(err error) bool
- func FilterRedisNilErr(err error) bool
- func FormFileValue(r *http.Request, key string) (string, error)
- func FormFileValues(r *http.Request, key string) ([]string, error)
- func FormIntDefault(r *http.Request, key string, def int) int
- func FormIntSliceDefault(r *http.Request, key, sep string, def []int) []int
- func GbkToUtf8(gbkData []byte) []byte
- func GetCurrentDirectory() string
- func GetIp(r *http.Request) string
- func GetJSON(URL string, v interface{}) ([]byte, error)
- func GetParentDirectory(dirctory string) string
- func GetRemoteIP(r *http.Request) string
- func GetToken(ctx *fiber.Ctx) (token string)
- func GetURL(URL string) ([]byte, error)
- func GetURLReceiveJSON(URL string, params url.Values, receive interface{}) error
- func GetUUid() string
- func GetValueURL(URL string, params url.Values) ([]byte, error)
- func GzipCompress(data string) ([]byte, error)
- func GzipUnCompress(data []byte) ([]byte, error)
- func HMACSHA1Hash(src, key []byte) []byte
- func HMACSHA1HexHash(src, key []byte) string
- func HasLocalIP(ip net.IP) bool
- func HasLocalIPddr(ip string) bool
- func Hash(ht crypto.Hash, b []byte) []byte
- func HashHex(ht crypto.Hash, b []byte) string
- func HmacSha256(data string, secret string) string
- func IP2Long(ip net.IP) (uint, error)
- func IPString2Long(ip string) (uint, error)
- func InArr(array []int, column int) bool
- func InMap(maps map[string]int, column string) (ok bool)
- func InstrArr(array []string, column string) bool
- func IsGBK(data []byte) bool
- func IsJson(str string) bool
- func IsSameDay(oldDay, anotherDay int64) bool
- func IsUtf8(data []byte) bool
- func IsValidIPv4(ip string) bool
- func JoinInt(s []int, sp string) string
- func LoadJSONConfig(filename string, v interface{}) error
- func Long2IP(i uint) (net.IP, error)
- func Long2IPString(i uint) (string, error)
- func MD5Hash(b []byte) []byte
- func MD5HexHash(b []byte) string
- func NewECBDecrypter(b cipher.Block) cipher.BlockMode
- func NewECBEncrypter(b cipher.Block) cipher.BlockMode
- func OpenWinBrowser(uri string) error
- func PKCS5Padding(ciphertext []byte, blockSize int) []byte
- func PKCS5UnPadding(origData []byte) ([]byte, error)
- func PostJSON(URL string, v interface{}) ([]byte, error)
- func PostJSONReceiveJSON(URL string, send, receive interface{}) error
- func PostMapReceiveJSON(URL string, maps map[string]string, receive interface{}) error
- func PostToJSON(URL string, v interface{}) ([]byte, error)
- func PostURL(URL string, params url.Values) ([]byte, error)
- func PostURLReceiveJSON(URL string, params url.Values, receive interface{}) error
- func PwdDecode(pwd string, key string) (string, error)
- func PwdEncode(pwd string, key string) string
- func RemoteIP(r *http.Request) string
- func SHA1HexHash(b []byte) string
- func SHA256HexHash(b []byte) string
- func SplitInt(s, sep string) ([]int, error)
- func Str2bytes(s string) (b []byte)
- func StrToBytes(s string) []byte
- func StringIsEmpty(s ...string) bool
- func Substr(str string, start, length int) string
- func WriteJSON(w io.Writer, v interface{}) (int, error)
- type Map
Constants ¶
const ( TimeFormat = "2006-01-02 15:04:05" TimeFormatDay = "20060102" TimeFormatDay2 = "2006-01-02" TimeFormatDay3 = "2006/01/02" )
Variables ¶
var TokenBucket sync.Map
Functions ¶
func AesDecryptCBC ¶
func AesEncryptCBC ¶
=================== CBC ======================
func BytesToStr ¶
func CheckFileIsExist ¶
func CheckParam ¶
检查http请求中是否包含所需参数 Deprecated: 使用CheckNotNil代替
func CheckRemoteIP ¶
CheckRemoteIP 验证IP in ips return true
func ClientIP ¶
ClientIP 尽最大努力实现获取客户端 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。
func ClientPublicIP ¶
ClientPublicIP 尽最大努力实现获取客户端公网 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。
func CreateAnyTypeSlice ¶
func CreateAnyTypeSlice(slice interface{}) ([]interface{}, bool)
interface{}转为 []interface{}
func CtxClientIP ¶
func CtxClientIP(ctx *fasthttp.RequestCtx) string
获取真实的IP 1.1.1.1, 2.2.2.2, 3.3.3.3
func CtxFormIntDefault ¶
FormIntDefault 获取Form参数 如果出错则返回默认值
func CtxGetURLReceiveJSON ¶
func FilterMysqlNilErr ¶
func FilterRedisNilErr ¶
func FormFileValue ¶
FormFileValue 快速获取表单提交的文件 也用于处理同表单一起提交的信息
func FormFileValues ¶
FormFileValues 快速获取表单提交的文件 也用于处理同表单一起提交的信息
func FormIntDefault ¶
FormIntDefault 获取Form参数 如果出错则返回默认值
func FormIntSliceDefault ¶
FormIntSliceDefault 获取Form参数 如果出错则返回默认值
func GetCurrentDirectory ¶
func GetCurrentDirectory() string
func GetParentDirectory ¶
func GetURLReceiveJSON ¶
GetURLReceiveJSON GET请求 自动解析JSON
func GetValueURL ¶
GetValueURL 请求URL 附带参数
func GzipCompress ¶
func GzipUnCompress ¶
func HMACSHA1HexHash ¶
HMACSHA1HexHash hmac-sha1 and encode to string
func HasLocalIP ¶
HasLocalIP 检测 IP 地址是否是内网地址 通过直接对比ip段范围效率更高,详见:https://github.com/thinkeridea/go-extend/issues/2
func HmacSha256 ¶
func LoadJSONConfig ¶
LoadJSONConfig 读取配置文件 json格式
func NewECBDecrypter ¶
NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given Block.
func NewECBEncrypter ¶
NewECBEncrypter returns a BlockMode which encrypts in electronic code book mode, using the given Block.
func OpenWinBrowser ¶
func PostJSONReceiveJSON ¶
PostJSONReceiveJSON POST请求 BODY为JSON格式 ContentType=application/json 自动解析JSON
func PostMapReceiveJSON ¶
PostURLReceiveJSON POST请求 自动解析JSON
func PostToJSON ¶
PostToJSON POST请求 BODY为json格式 Deprecated: Please use PostJSON to replace
func PostURLReceiveJSON ¶
PostURLReceiveJSON POST请求 自动解析JSON