Documentation ¶
Index ¶
- Constants
- Variables
- func Apply(obj_func any, args []any) []reflect.Value
- func Assign(a, b any) any
- func Atob(s string) string
- func Atob2Bytes(s string) []byte
- func B2S(b []byte) string
- func Btoa(s string) string
- func BtoaBytes(bytes []byte) string
- func Call(obj_func any, args ...any) []reflect.Value
- func CallMethod(obj any, methodName string, args ...any) []reflect.Value
- func FmtString(src string, data map[string]any) string
- func GetField(obj any, name string) (reflect.StructField, bool)
- func GetFieldValu(obj any, name string) reflect.Value
- func GetFieldValueWithLower(obj any, name string) reflect.Value
- func GetKind(v any) reflect.Kind
- func GetReflectType(v any) reflect.Type
- func GetReflectValue(v any) reflect.Value
- func GetStructTypeName(v any) string
- func GetTag(obj struct{}, name, tagName string) string
- func GetType(v any) string
- func GetTypeEnum(value any) int
- func Has(obj any, name string) bool
- func IsBool(v any) bool
- func IsInt(v any) bool
- func IsMap(v any) bool
- func IsPtr(v any) bool
- func IsString(v any) bool
- func IsStringBlank(str string) bool
- func IsStringEmail(value string) bool
- func IsStringNumber(str string) bool
- func IsStringURL(str string) bool
- func IsTime(v any) bool
- func IsValidNumber(value any) bool
- func Map2Struct(m map[string]any, s struct{}) error
- func Max[T Number](a, b T) T
- func New(v any) any
- func NewSlice(v any) any
- func Panic(err error, msg string)
- func ParseBool(str string) bool
- func ParseFloat32(str string) float32
- func ParseFloat64(str string) float64
- func ParseHex(str string) uint64
- func ParseInt(str string) int
- func ParseInt16(str string) int16
- func ParseInt32(str string) int32
- func ParseInt64(str string) int64
- func ParseInt8(str string) int8
- func ParseUint(str string) uint
- func ParseUint64(str string) uint64
- func Round(f float64, n int) float64
- func RoundInt(f float64) int
- func S2B(s string) []byte
- func SetInterval(callback func(), delay time.Duration) func()
- func SetSleep(action func() bool, delay int)
- func SetStructValue(obj any, name string, value any) error
- func SetTimeout(callback func(), delay time.Duration) func()
- func SplitLines(s string) []string
- func SplitLines2(s string) []string
- func SplitWords(s string) []string
- func StringReverse(s string) string
- func StringReverseOffset(s string, offset rune) string
- func StructToMap(s any, tag string, methodName string) (res map[string]any, err error)
- func TimeCost() func(name string)
- func ToCamelCase(val string) string
- func ToSliceReflectValue(args []any) []reflect.Value
- func ToSnakeCase(val string) string
- func Unicode2ZH(from string) string
- type Builder
- func (b *Builder) AddBool(name string, tag string) *Builder
- func (b *Builder) AddField(field string, typ reflect.Type, tag string) *Builder
- func (b *Builder) AddFloat64(name string, tag string) *Builder
- func (b *Builder) AddFunc(name string, tag string) *Builder
- func (b *Builder) AddInt64(name string, tag string) *Builder
- func (b *Builder) AddString(name string, tag string) *Builder
- func (b *Builder) AddStringSlice(name string, tag string) *Builder
- func (b *Builder) Build() *Struct
- type Instance
- func (i *Instance) Addr() any
- func (in Instance) Field(name string) (reflect.Value, error)
- func (i *Instance) Interface() any
- func (in *Instance) SetBool(name string, value bool)
- func (in *Instance) SetFloat64(name string, value float64)
- func (in *Instance) SetFunc(name string, value func())
- func (in *Instance) SetInt64(name string, value int64)
- func (in *Instance) SetString(name, value string)
- func (in *Instance) SetStringSlice(name string, value []string)
- type Number
- type Struct
Constants ¶
const ( String = iota Int32 Int64 Unknown )
const ( OptIgnore = "-" // 忽略当前这个域 OptOmitempty = "omitempty" // 当这个域的值为空,忽略这个域 OptDive = "dive" // 递归地遍历这个结构体,将所有字段作为键 OptWildcard = "wildcard" // 只适用于字符串类型,返回"%"+值+"%",这是为了方便数据库的模糊查询 )
Variables ¶
var (
FieldNoExist error = errors.New("field no exist")
)
Functions ¶
func CallMethod ¶
CallMethod @param obj 为结构体指针
func GetFieldValueWithLower ¶ added in v1.1.2
func GetReflectValue ¶ added in v1.1.2
GetType 获取数据值(不包括指针)
func GetType ¶
GetType 没办法判断time.Time GetType(string) == "string" GetType(int) == "int" GetType(int32) == "int32" GetType(int64) == "int64"
func GetTypeEnum ¶ added in v1.1.1
func IsValidNumber ¶ added in v1.1.1
func ParseBool ¶
ParseBool 将字符串转换为布尔值 它接受真值:1, t, T, TRUE, true, True 它接受假值:0, f, F, FALSE, false, False. 其它任何值都返回一个错误
func ParseFloat64 ¶
类似于javascript,全局的parseInt、parseFloat 需要去掉首尾空格,否则可能会解析为0 ParseFloat64
func SetInterval ¶ added in v1.1.2
SetInterval 间隔delay毫秒执行一次
func SetStructValue ¶ added in v1.1.1
SetStructValue 设置结构体的值
func SetTimeout ¶ added in v1.1.2
SetTimeout 毫秒
func SplitWords ¶ added in v1.1.1
SplitWords 以连续的空白字符为分隔符,将s切分成多个子串,结果中不包含空白字符本身。 空白字符有:\\t, \\n, \\v, \\f, \\r, ’ ‘, U+0085 (NEL), U+00A0 (NBSP) 。 如果 s 中只包含空白字符,则返回一个空列表\n
func StringReverseOffset ¶
StringReverseOffset
func StructToMap ¶
StructToMap 结构体转map fn.StructToMap(struct, "map", "")
func ToCamelCase ¶
ToCamelCase ToCamelCase("camel-case") == "camelCase"
func ToSnakeCase ¶
ToSnakeCase ToSnakeCase("snakeCase") == "snake-case"
Types ¶
type Builder ¶ added in v1.1.1
type Builder struct {
// contains filtered or unexported fields
}
@see https://github.com/gaofeng-lin/codehome
func NewStructBuilder ¶ added in v1.1.1
func NewStructBuilder() *Builder
func (*Builder) AddFloat64 ¶ added in v1.1.1
func (*Builder) AddStringSlice ¶ added in v1.1.1
type Instance ¶ added in v1.1.1
type Instance struct {
// contains filtered or unexported fields
}
结构体的值
func (*Instance) SetFloat64 ¶ added in v1.1.1
func (*Instance) SetStringSlice ¶ added in v1.1.1
Source Files ¶
- apply.go
- cvt_b2s.go
- cvt_map2struct.go
- cvt_s2b.go
- getStructTypeName.go
- get_kind.go
- get_type.go
- get_type_enum.go
- has.go
- isBool.go
- isInt.go
- isMap.go
- isPtr.go
- isString.go
- isStringBlank.go
- isStringEmail.go
- isStringNumber.go
- isStringURL.go
- isTime.go
- isValidNumber.go
- js_assign.go
- js_atob.go
- js_btoa.go
- js_setInterval.go
- js_setTimeout.go
- max.go
- new.go
- new_struct.go
- panic.go
- round.go
- sleep.go
- split_lines.go
- split_words.go
- string.go
- string_fmt.go
- string_reverse.go
- struct2map.go
- timecost.go
- toCamelCase.go
- toSnakeCase.go
- unicode2zh.go