fplib

package module
v0.0.0-...-16eaaa9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2019 License: GPL-3.0 Imports: 21 Imported by: 1

README

fplib

golang 常用功能库

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	JSON *JSONClass = &JSONClass{}
	Str  *StrClass  = &StrClass{}
)

Functions

func Base64Decode

func Base64Decode(str string) []byte

func Base64Encode

func Base64Encode(str string) string

func Bool

func Bool(obj interface{}) bool

判断是否是布尔真值,支持字符串的true和false等写法

func Datetime

func Datetime() string

"2006-01-02 15:04:05 -0700 MST"

func Datetime_ms

func Datetime_ms() string

func Debug

func Debug(msgs ...interface{})

func DeepCopy

func DeepCopy(value interface{}) interface{}

深拷贝

func Default

func Default(obj interface{}, def interface{}) interface{}

如果变量为空,设置变量的默认值

func DetermineEncoding

func DetermineEncoding(r *bufio.Reader) (encoding.Encoding, error)

检测编码类型

func Empty

func Empty(obj interface{}) bool

判断变量是否为空

func Error

func Error(msgs ...interface{})

func Float32

func Float32(obj interface{}, defaults ...float32) float32

func Float64

func Float64(obj interface{}, defaults ...float64) float64

func GBKToUTF8

func GBKToUTF8(s []byte) ([]byte, error)

gbk转utf8

func If

func If(condition bool, trueVal, falseVal interface{}) interface{}

三元运算符hack

func InDebug

func InDebug() bool

func In_Array

func In_Array(array interface{}, val interface{}) bool

反射方式获取变量是否在数组中

func In_Array_Index

func In_Array_Index(array interface{}, val interface{}) int

反射方式获取变量是否在数组中,如果存在返回索引,不存在返回-1

func Int

func Int(obj interface{}, defaults ...int) int

转换为int型

func Int64

func Int64(obj interface{}, defaults ...int64) int64

转换为int型

func IsBlank

func IsBlank(value reflect.Value) bool

func MD5

func MD5(str string) string

func MapGetString

func MapGetString(m *map[string]interface{}, key string, defaults ...string) string

从map[string]interface{}中获取字符串

func ShowType

func ShowType(msgs ...interface{})

func String

func String(obj interface{}, defaults ...string) string

转换为string型

func Timestamp

func Timestamp() int64

func Timestamp_ms

func Timestamp_ms() int64

func Timestamp_ns

func Timestamp_ns() int64

func ToUTF8

func ToUTF8(r io.Reader) ([]byte, error)

转utf8,自动检测类型

func Trim

func Trim(strs ...string) string

支持多字符连续处理的trim

func Typeof

func Typeof(v ...interface{}) string

获取变量的类型名称

func UTF8ToGBK

func UTF8ToGBK(s []byte) ([]byte, error)

utf8转gbk

Types

type Conf

type Conf struct {
	// contains filtered or unexported fields
}

func (*Conf) Get

func (this *Conf) Get(key string) interface{}

func (*Conf) GetBool

func (this *Conf) GetBool(key string, defaults ...bool) bool

func (*Conf) GetInt

func (this *Conf) GetInt(key string, defaults ...int) int

func (*Conf) GetString

func (this *Conf) GetString(key string, defaults ...string) string

func (*Conf) Set

func (this *Conf) Set(key string, value interface{}) *Conf

type JSONClass

type JSONClass struct {
}

func (*JSONClass) Arr

func (this *JSONClass) Arr(objs ...interface{}) *SJSON

生成sjson数组

func (*JSONClass) Debug

func (this *JSONClass) Debug(objs ...interface{})

输出可阅读格式

func (*JSONClass) Obj

func (this *JSONClass) Obj(obj ...interface{}) *SJSON

生成sjson对象

func (*JSONClass) Parse

func (this *JSONClass) Parse(json string) gjson.Result

gjson的parse

func (*JSONClass) ParseFile

func (this *JSONClass) ParseFile(filename string) gjson.Result

func (*JSONClass) ParseJSON

func (this *JSONClass) ParseJSON(str string) (interface{}, error)

标准库的parse

func (*JSONClass) ParseObj

func (this *JSONClass) ParseObj(str string, obj interface{}) error

标准库的parse,自定义结构体

func (*JSONClass) Show

func (this *JSONClass) Show(obj interface{}) string

输出可阅读格式

func (*JSONClass) Stringify

func (this *JSONClass) Stringify(obj interface{}) string

标准库的序列化

func (*JSONClass) ToObj

func (this *JSONClass) ToObj(obj interface{}) interface{}

将gjson,sjson转换为标准interface

type SJSON

type SJSON struct {
	Json string
}

func (*SJSON) CamelString

func (this *SJSON) CamelString() *SJSON

func (*SJSON) Delete

func (this *SJSON) Delete(k string) *SJSON

func (*SJSON) Filter

func (this *SJSON) Filter(ps ...string) *SJSON

根据key过滤,ps[0]包含的key,为空包含所有key,ps[1]排除的key

func (*SJSON) GJSON

func (this *SJSON) GJSON() gjson.Result

获取gjson对象,方便查询

func (*SJSON) Get

func (this *SJSON) Get(key string) gjson.Result

使用gjson的get方法

func (*SJSON) IsArray

func (this *SJSON) IsArray() bool

是否是数组

func (*SJSON) IsEmpty

func (this *SJSON) IsEmpty() bool

是否为空

func (*SJSON) Obj

func (this *SJSON) Obj() interface{}

func (*SJSON) Parse

func (this *SJSON) Parse(obj interface{}) *SJSON

从字符串,gjson,sjson,结构体获得sjson

func (*SJSON) Set

func (this *SJSON) Set(k string, p interface{}) *SJSON

func (*SJSON) SetArr

func (this *SJSON) SetArr(p ...interface{}) *SJSON

func (*SJSON) SetMap

func (this *SJSON) SetMap(maps map[string]interface{}) *SJSON

func (*SJSON) Show

func (this *SJSON) Show() string

func (*SJSON) SnakeString

func (this *SJSON) SnakeString() *SJSON

func (*SJSON) String

func (this *SJSON) String() string

type StrClass

type StrClass struct{}

func (*StrClass) CamelString

func (this *StrClass) CamelString(s string) string

camel string, xx_yy to XxYy

func (*StrClass) EndWith

func (this *StrClass) EndWith(str, find string) bool

func (*StrClass) EndWithi

func (this *StrClass) EndWithi(str, find string) bool

func (*StrClass) FromArr

func (this *StrClass) FromArr(arr []string) string

数组转换为字符串

func (*StrClass) FromArr2

func (this *StrClass) FromArr2(arr []string, c string) string

数组转换为字符串,可定义分隔符

func (*StrClass) Has

func (this *StrClass) Has(str, find string) bool

func (*StrClass) Hasi

func (this *StrClass) Hasi(str, find string) bool

func (*StrClass) In_Array

func (this *StrClass) In_Array(array []string, val string) bool

数组中是否包含

func (*StrClass) In_Array_Index

func (this *StrClass) In_Array_Index(array []string, val string) int

数组中是否包含指定字符串,如果存在返回索引,不存在返回-1

func (*StrClass) In_Array_Indexi

func (this *StrClass) In_Array_Indexi(array []string, val string) int

忽略大小写版本

func (*StrClass) In_Arrayi

func (this *StrClass) In_Arrayi(array []string, val string) bool

func (*StrClass) RemoveRepeatedFromArr

func (this *StrClass) RemoveRepeatedFromArr(arr []string) []string

字符串数组去重

func (*StrClass) SnakeString

func (this *StrClass) SnakeString(s string) string

snake string, XxYy to xx_yy , XxYY to xx_yy

func (*StrClass) StartWith

func (this *StrClass) StartWith(str, find string) bool

func (*StrClass) StartWithi

func (this *StrClass) StartWithi(str, find string) bool

func (*StrClass) ToArr

func (this *StrClass) ToArr(strs ...string) []string

字符串转换为数组

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL