Documentation ¶
Index ¶
- Constants
- func ClientIP(r *http.Request) string
- func Date(phpFormat string, stamp int64) string
- func GBK2UTF8(str []byte) ([]byte, error)
- func GetAppDir() string
- func GetPost(method string, sUrl string, data map[string]string, head map[string]string, ...) (string, error)
- func GetPostRequest(method string, sUrl string, data map[string]string, head map[string]string, ...) (*http.Response, error)
- func Go(x func())
- func InnerIP(ip string) bool
- func LocalIPV4() string
- func Md5(s string) string
- func Mod(id int64) int64
- func RandInt(start, end int64) (int64, error)
- func RandInt2(start, end int64) int64
- func SignPost(domain string, key string, secret string, control string, method string, ...) (string, error)
- func SortBuildQuery(data map[string]interface{}) string
- func StampToTimeStamp(stamp int64, phpFormat string) int64
- func StrToTime(phpFormat string, timeStr string) int64
- func Time() int64
- func UTF82GBK(str []byte) ([]byte, error)
- func WriteFile(fileName string, content []byte) error
Constants ¶
View Source
const TIME_STR = "2006-01-02 15:04:05"
View Source
const TIME_STRS = "2006-01-02 15:04"
Variables ¶
This section is empty.
Functions ¶
func ClientIP ¶
ClientIP 尽最大努力实现获取客户端 IP 的算法。 解析 X-Real-IP 和 X-Forwarded-For 以便于反向代理(nginx 或 haproxy)可以正常工作。
func Date ¶
Date 支持最常用的 Y-m-d H:i:s 2006-01-02 15:04:05 2006-01-02 15:04:05000 stamp 时间戳 如果为0则处理为当前时间
func GetAppDir ¶
func GetAppDir() string
GetAppDir 获取到可执行文件的绝对地址 调试环境下返回 源码的路径 正式环境下返回 可执行文件的路径 区分 go run 下执行 还是 go build 之后的可执行文件 按系统区分
func GetPost ¶
func GetPost(method string, sUrl string, data map[string]string, head map[string]string, cookie []*http.Cookie) (string, error)
GetPost 发送get 或 post请求 获取数据
func GetPostRequest ¶
func GetPostRequest(method string, sUrl string, data map[string]string, head map[string]string, cookie []*http.Cookie, redirect bool) (*http.Response, error)
GetPostRequest 发送get 或 post请求 获取数据 返回response和error
func SignPost ¶
func SignPost(domain string, key string, secret string, control string, method string, data map[string]string) (string, error)
SignPost 加密发送post请求到接口
func SortBuildQuery ¶ added in v0.0.17
SortBuildQuery 只支持一级 生成url 查询字符串
func StampToTimeStamp ¶
StampToTimeStamp 将时间戳 按指定格式 转换为新的时间戳 仅支持最常用的 Y-m-d H:i:s 仅支持最常用的 Y-m-d stamp 时间戳 如果为0则处理为当前时间
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.