Documentation ¶
Index ¶
- func AddJSONFormTag(in string) string
- func FiltTag(tag string) string
- func FindUpperElement(s string) []string
- func HumpToUnderLine(s string) string
- func IfZero(arg interface{}) bool
- func In(s string, arr []string) bool
- func MD5(rawMsg string) string
- func Obj2MapByJson(obj interface{}) (map[string]interface{}, error)
- func Obj2MapByReflect(obj interface{}) map[string]interface{}
- func RetryHandler(n int, f func() (bool, error)) error
- func SmartPrint(i interface{}, escapeZero ...bool)
- func Split(s string, sub string) []string
- func Split2(s string, sub string, tmp *string, rs *[]string)
- func TableToStruct(dataSource string, tableName string) string
- func ToLimitOffset(sizeIn string, indexIn string, count int) (limit int, offset int)
- func ToParam(vx interface{}, tag string) string
- func ToString(arg interface{}) string
- func UnderLineToHump(s string) string
- type Column
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddJSONFormTag ¶
AddJSONFormTag add json and form tag for a golang struct without tag and annotation
func FindUpperElement ¶
FindUpperElement 找到字符串中大写字母的列表,附属于HumpToUnderLine
func IfZero ¶
func IfZero(arg interface{}) bool
To judge a value whether zero or not. By the way, '%' '%%' is regarded as zero.
func Obj2MapByJson ¶
Transer an obj to a map by json
func Obj2MapByReflect ¶
func Obj2MapByReflect(obj interface{}) map[string]interface{}
Transer an obj to a map by reflect
func RetryHandler ¶
Execute a function n times, the function as the handler should be well format to func() (bool,error). Bool stands for its ok or not ,error stands for its error Example:
f := func() (bool, error) { fmt.Println("connect to mysql") return false, errors.New("time out") } if e := RetryHandler(3, f); e != nil { fmt.Println(e.Error()) }
func SmartPrint ¶
func SmartPrint(i interface{}, escapeZero ...bool)
To well print a struct type value Example:
type User struct{ Name string Age int Sal float64 Friends []User } user := User{ Name:"ft", Age: 9, Sal: 1000, Friends: []User{User{"f1" , 11, 0.,nil},{"f2" , 12, 0.,nil}}, } SmartPrint(user)
If you want those zero value not print,use it like `SmartPrint(user, true)`
func TableToStruct ¶
postgres数据库表转go model 使用时注入驱动 _ "github.com/jinzhu/gorm/dialects/postgres"
func ToLimitOffset ¶
generate limit offset by page size , page index , total count
func ToParam ¶
Convert a struct type value into a format string as a=x&&b=y&&c=z sorted by key asc like a=x&b=y&c=z not b=y,a=x,c=z