Documentation ¶
Index ¶
- Constants
- func AddFormFile(writer *multipart.Writer, name, path string) error
- func AddParams(url_ string, params url.Values) string
- func ArrayToString(array []interface{}) string
- func Base64Decode(code string) string
- func Base64Encode(s string) string
- func Base64URLDecode(data string) string
- func Base64UrlSafeEncode(data string) string
- func CheckParamFile(params url.Values) bool
- func CheckParamsType(v interface{}) int
- func CreateOrder() int64
- func EncodeURLParams(bm map[string]interface{}, order int) string
- func Exists(filePath string) bool
- func Fail(c *gin.Context)
- func FailAuthMessage(c *gin.Context, message string)
- func FailAuthsMessage(c *gin.Context, message string)
- func FailNotMessage(c *gin.Context, message string)
- func FailWithDetailed(c *gin.Context, data interface{}, message string)
- func FailWithMessage(c *gin.Context, message string)
- func Find(slice []int, val int) (int, bool)
- func GenValidateCode(width int) string
- func GenerateTraceId() string
- func GetAddressByIP(ipA string) string
- func GetClientIp() string
- func GetLocalIPs() (ips []string)
- func GetLock(redisConn *redis.Client, lockName string, ...) (string, error)
- func GetRandomString(l int) string
- func GetRandomString6(n uint64) []byte
- func GetRequestIdKey(c *gin.Context) (requestId string)
- func GetString(d interface{}) string
- func InSliceString(k string, s []string) bool
- func IsNil(obj interface{}) bool
- func MD5V(str []byte, b ...byte) string
- func Md5(s string) string
- func MergeHeaders(headers ...map[string]string) map[string]string
- func MergeOptions(options ...map[int]interface{}) map[int]interface{}
- func Ok(c *gin.Context)
- func OkWithData(c *gin.Context, data interface{})
- func OkWithDetailed(c *gin.Context, data interface{}, message string)
- func OkWithMessage(c *gin.Context, message string)
- func ReleaseLock(redisConn *redis.Client, lockName, code string) bool
- func RemoteIp(req *http.Request) string
- func Result(c *gin.Context, code int, data interface{}, msg string)
- func SingCheng(bm map[string]interface{}, sign string, order int) bool
- func StructToMap(obj interface{}) map[string]interface{}
- func Strval(value interface{}) string
- func ToReader(v interface{}) *bytes.Reader
- func ToUrlValues(v interface{}) url.Values
- func ZipFiles(filename string, files []string, oldForm, newForm string) error
- type Response
- type Time
- func (t Time) Equal(other Time) bool
- func (t Time) ExactEqual(other Time) bool
- func (t Time) IsZero() bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) MarshalText() ([]byte, error)
- func (t Time) Ptr() *time.Time
- func (t *Time) SetValid(v time.Time)
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t *Time) UnmarshalText(text []byte) error
- func (t Time) Value() (driver.Value, error)
- func (t Time) ValueOrZero() time.Time
Constants ¶
const ( XForwardedFor = "X-Forwarded-For" XRealIP = "X-Real-IP" XtraceKey = "trace-id" //外部链路ID RequestIdKey = "request-id" //链路ID TimeFormat = "2006-01-02 15:04:05" //默认时间 )
Variables ¶
This section is empty.
Functions ¶
func AddFormFile ¶
Add a file to a multipart writer.
func ArrayToString ¶
func ArrayToString(array []interface{}) string
func Base64Decode ¶
func Base64Encode ¶
func Base64URLDecode ¶
Base64URLDecode 因为Base64转码后可能包含有+,/,=这些不安全的URL字符串,所以要进行换字符 '+' -> '-' '/' -> '_' '=' -> ” 字符串长度不足4倍的位补"="
func Base64UrlSafeEncode ¶
func CheckParamsType ¶
func CheckParamsType(v interface{}) int
func EncodeURLParams ¶
EncodeURLParams 获取sign 加密 order = 1 正序 order =2 倒叙
func FailAuthMessage ¶
func FailAuthsMessage ¶
func FailNotMessage ¶
func FailWithDetailed ¶
func FailWithMessage ¶
func GetLocalIPs ¶
func GetLocalIPs() (ips []string)
func GetLock ¶
func GetLock(redisConn *redis.Client, lockName string, acquireTimeout, lockTimeOut time.Duration) (string, error)
GetLock acquireTimeout Get the lock timeout period, If no lock is obtained within this period, err will be returned here lockTimeOut Lock timeout to prevent deadlock, lock automatically unlocked by this time
func GetRequestIdKey ¶
GetRequestIdKey 获取链路ID
func InSliceString ¶
InSliceString string是否在[]string里面
func MergeHeaders ¶
Merge headers(latter ones have higher priority)
func MergeOptions ¶
Merge options(latter ones have higher priority)
func OkWithData ¶
func OkWithDetailed ¶
func OkWithMessage ¶
func ReleaseLock ¶
ReleaseLock var count = 0 // test assist
func StructToMap ¶
func StructToMap(obj interface{}) map[string]interface{}
func ToUrlValues ¶
Types ¶
type Time ¶
Time is a nullable time.Time. It supports SQL and JSON serialization. It will marshal to null if null.
func TimeFromPtr ¶
TimeFromPtr creates a new Time that will be null if t is nil.
func (Time) Equal ¶
Equal returns true if both Time objects encode the same time or are both null. Two times can be equal even if they are in different locations. For example, 6:00 +0200 CEST and 4:00 UTC are Equal.
func (Time) ExactEqual ¶
ExactEqual returns true if both Time objects are equal or both null. ExactEqual returns false for times that are in different locations or have a different monotonic clock reading.
func (Time) IsZero ¶
IsZero returns true for invalid Times, hopefully for future omitempty support. A non-null Time with a zero value will not be considered zero.
func (Time) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It will encode null if this time is null.
func (Time) MarshalText ¶
MarshalText implements encoding.TextMarshaler. It returns an empty string if invalid, otherwise time.Time's MarshalText.
func (Time) Ptr ¶
Ptr returns a pointer to this Time's value, or a nil pointer if this Time is null.
func (*Time) UnmarshalJSON ¶
func (*Time) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler. It has backwards compatibility with v3 in that the string "null" is considered equivalent to an empty string and unMarshaling will succeed. This may be removed in a future version.
func (Time) ValueOrZero ¶
ValueOrZero returns the inner value if valid, otherwise zero.