Documentation
¶
Index ¶
- Constants
- func CheckCharYesNo(s string) bool
- func CheckIntRange(n, min, max int) bool
- func CheckStringLength(s string, min, max int) bool
- func CloseDefaultLogger() error
- func GetAesCryptoKey() string
- func IsDate(s string) bool
- func IsHexString(s string) bool
- func IsTime(s string) bool
- func IsWeekEnd(d time.Weekday) bool
- func LogDebug(v ...interface{})
- func LogInfo(v ...interface{})
- func MD5(data string) string
- func SHA1(data string) string
- func SHA256(data string) string
- func SHA512(data []byte) ([]byte, error)
- func SetAesCryptoKey(password string)
- func Str2Date(s string) (t time.Time, err error)
- func Str2Time(s string) (t time.Time, err error)
- func StrFmtTime(s, fmt string) (t time.Time, err error)
- func StrLen(s string) int
- func Time2Str(t time.Time) string
- func TimeFmtStr(t time.Time, fmt string) string
- type AesCrypto
- type Logger
- type ReplyData
- func ErrReplyData(status int, message string) *ReplyData
- func ErrorsReplyData(status int, errors map[string]string) *ReplyData
- func NewReplyData(status int) *ReplyData
- func OkReplyData() *ReplyData
- func RowReplyData(row interface{}) *ReplyData
- func RowsReplyData(total, pageCount int, rows interface{}) *ReplyData
Constants ¶
View Source
const ( TimeFmtLong = `2006-01-02 15:04:05` // yyyy-MM-dd hh:mm:ss TimeFmtNumeric = `20060102150405` // yyyyMMddhhmmss DateFmtLong = `2006-01-02` // yyyy-MM-dd DateFmtNumeric = `20060102` // yyyyMMdd )
Time fmt
View Source
const ( ErrOk = 0 ErrNotFound = 1001 // ErrNotFound 404 route not found ErrException = 1002 // ErrException 500 ErrBadRequest = 1003 // ErrBadRequest 400 route params error ErrMethodNotAllowed = 1004 // ErrMethodNotAllowed 405 ErrParamsError = 1005 // ErrParamsError 415 ErrUnAuthorized = 1006 // ErrUnAuthorized 401 ErrDataNotFound = 1007 // ErrDataNotFound 404 ErrNotAllowed = 1008 // ErrNotAllowed 405 ErrDataExists = 1009 // ErrDataExists 400 ErrDataValidate = 1010 // ErrDataValidate 403 VarUserAuthorization = `access_token` // oauth token HTTPHeaderAuthorization = `Authorization` // HTTP header Authorization HTTPHeaderToken = `X-Token` // HTTP header Authorization X-Token )
Error code & constant
View Source
const ( LibName = `tyr` // LibName toolkit name Go micro service LibVersion = `0.4.0` // LibVersion toolkit version )
Library constant
Variables ¶
This section is empty.
Functions ¶
func CheckStringLength ¶
CheckStringLength 检测字符串是否符合指定长度范围
func SetAesCryptoKey ¶
func SetAesCryptoKey(password string)
SetAesCryptoKey set key, key length:16, 24, 32 bytes to AES-128, AES-192, AES-256
Types ¶
type AesCrypto ¶
type AesCrypto struct {
Key []byte
}
AesCrypto define
type Logger ¶
Logger logger
func NewDefaultLogger ¶
NewDefaultLogger defult logger
func ReopenDefaultLogger ¶
ReopenDefaultLogger re open default logger
type ReplyData ¶
type ReplyData struct { Status int `json:"status" xml:"status"` // Status code Message string `json:"message" xml:"message"` // Message description Errs map[string]string `json:"errors,omitempty" xml:"errors,omitempty"` // Errs errors PageCount int `json:"pageCount,omitempty"` Total int `json:"total,omitempty" xml:"total,omitempty"` // Total data total List interface{} `json:"rows,omitempty" xml:"rows,omitempty"` // List data list Data interface{} `json:"data,omitempty" xml:"data,omitempty"` // Data data attribute }
ReplyData define API output data
func ErrReplyData ¶
ErrReplyData creates and return ReplyData with error and message
func ErrorsReplyData ¶
ErrorsReplyData creates and return ReplyData with errors
func NewReplyData ¶
NewReplyData creates and return ReplyData with status and message
func RowReplyData ¶
func RowReplyData(row interface{}) *ReplyData
RowReplyData creates and return ReplyData with attr row
func RowsReplyData ¶
RowsReplyData creates and return ReplyData with total and list
Source Files
¶
Click to show internal directories.
Click to hide internal directories.