Documentation
¶
Index ¶
- func Base64Decode(str string) (string, error)
- func Base64Encode(str string) string
- func CheckAndSetDefault(i interface{}) error
- func CopyFile(src, dst string, overwrite bool, perm os.FileMode, copyAttr bool) error
- func CopyFileAttr(src, dst string) error
- func CreateFile(path string, content []byte, perm os.FileMode, overwrite bool) error
- func CreateFileIfNotExist(path string, content []byte, perm os.FileMode, overwrite bool) errordeprecated
- func DirExists(path string, create bool, perm os.FileMode) (bool, error)
- func DirName(path string) string
- func FileExists(path string) bool
- func GenerateSSHKey() error
- func GetAbsPath(path string) (string, error)
- func GetFieldNameByJSONTag(objType reflect.Type, jsonKey string) string
- func GetHostInfo(req *http.Request) string
- func GetSSHKey() (string, error)
- func InArray(val interface{}, array interface{}) (exists bool)
- func Int(i int) *int
- func IsDir(path string) bool
- func IsEmpty(path string) bool
- func IsEmptyDir(path string) bool
- func IsEmptyFile(path string) bool
- func IsError(errs []error) bool
- func IsExecutable(path string) bool
- func IsFile(path string) bool
- func IsHidden(path string) bool
- func IsReadable(path string) bool
- func IsSymlink(path string) bool
- func IsWritable(path string) bool
- func JsonStr2Map(str string) map[string]interface{}
- func JsonStrSort(jsonStr string) string
- func MapToStruct(mapData interface{}, obj interface{})
- func ParseIP(s string) (net.IP, int)
- func Random(length int, numericOnly bool) string
- func ReadJsonFile(filePath string, data any) error
- func Remove(path string) error
- func Str2Int(str string) intdeprecated
- func StrReplace(search interface{}, replace interface{}, subject interface{}, count int) (interface{}, error)
- func StringEndWith(str, suffix string) bool
- func StringStartWith(str, prefix string) bool
- func StructToMap(obj interface{}, useJsonTag bool) map[string]interface{}
- func ToArrByte(value interface{}) (arrByte []byte)
- func ToBool(value interface{}) (b bool)
- func ToFileMode(value interface{}) (mode os.FileMode)
- func ToInt(value interface{}) (i int)
- func ToString(value interface{}) (key string)
- type ArrStr
- type JsonHelper
- func (jh *JsonHelper) DoSort() *JsonHelper
- func (jh *JsonHelper) Errors() []error
- func (jh *JsonHelper) HasError() bool
- func (jh *JsonHelper) MakeFile(filepath string) *JsonHelper
- func (jh *JsonHelper) ToFile() *JsonHelper
- func (jh *JsonHelper) ToJson() (string, error)
- func (jh *JsonHelper) ToMap(newMap *map[string]interface{}) *JsonHelper
- func (jh *JsonHelper) ToString(newStr *string) *JsonHelper
- func (jh *JsonHelper) ToStruct(newStruct interface{}) *JsonHelper
- type MapHelper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶ added in v0.6.1
Base64Decode base64解密
func CheckAndSetDefault ¶ added in v0.6.1
func CheckAndSetDefault(i interface{}) error
CheckAndSetDefault 检查结构体中的字段是否为空,如果为空则设置为默认值
func CreateFile ¶ added in v0.2.1
CreateFile 创建文件,可设置文件权限,可设置是否覆盖
func GetFieldNameByJSONTag ¶ added in v0.6.1
GetFieldNameByJSONTag 根据 JSON 标记获取结构体字段名
func GetHostInfo ¶ added in v0.6.1
GetHostInfo 从http.Request中获取hostInfo
func JsonStr2Map ¶ added in v0.1.2
JsonStr2Map Deprecated: 请使用 JsonHelper.ToMap
func JsonStrSort ¶ added in v0.1.2
JsonStrSort 根据map的key进行排序 Deprecated: 请使用
func MapToStruct ¶ added in v0.6.1
func MapToStruct(mapData interface{}, obj interface{})
MapToStruct 通过reflect将map转换为结构体
func ReadJsonFile ¶
ReadJsonFile 读取json文件,并解析到结构体
func StrReplace ¶ added in v0.1.2
func StrReplace(search interface{}, replace interface{}, subject interface{}, count int) (interface{}, error)
StrReplace 类似于php中的str_replace
func StringEndWith ¶ added in v0.3.1
StringEndWith 判断字符串是否以某个字符串结尾
func StringStartWith ¶ added in v0.3.1
StringStartWith 判断字符串是否以某个字符串开头
func StructToMap ¶ added in v0.6.1
StructToMap 通过reflect将结构体转换为map
func ToArrByte ¶ added in v0.2.1
func ToArrByte(value interface{}) (arrByte []byte)
ToArrByte 将变量转为[]byte类型
func ToFileMode ¶ added in v0.2.1
ToFileMode 将变量转为os.FileMode类型
Types ¶
type ArrStr ¶ added in v0.1.2
func (*ArrStr) ArrayIntersect ¶ added in v0.1.2
func (*ArrStr) ArrayValue ¶ added in v0.1.2
type JsonHelper ¶ added in v0.6.1
type JsonHelper struct {
Struct interface{} // 结构体
String string // json字符串
Map map[string]interface{} // map
// contains filtered or unexported fields
}
func JsonFile ¶ added in v0.3.1
func JsonFile(path string) *JsonHelper
JsonFile 根据传入的文件路径自动读取文件中的json内容 path: json文件路径
func JsonMap ¶ added in v0.6.1
func JsonMap(jsonMap map[string]interface{}) *JsonHelper
func JsonString ¶ added in v0.3.1
func JsonString(jsonString string) *JsonHelper
func JsonStruct ¶ added in v0.3.1
func JsonStruct(jsonStruct interface{}) *JsonHelper
func SetStruct ¶ added in v0.1.2
func SetStruct(jsonStruct interface{}) *JsonHelper
SetStruct Deprecated: 请使用 JsonStruct
func (*JsonHelper) DoSort ¶ added in v0.6.1
func (jh *JsonHelper) DoSort() *JsonHelper
DoSort 输出json字符串时是否根据key排序 Deprecated: 不再支持自动排序,有需求时通过MapHelper去排序
func (*JsonHelper) HasError ¶ added in v0.6.1
func (jh *JsonHelper) HasError() bool
HasError 判断是否有错误
func (*JsonHelper) MakeFile ¶ added in v0.6.1
func (jh *JsonHelper) MakeFile(filepath string) *JsonHelper
MakeFile 是否生成json文件
func (*JsonHelper) ToFile ¶ added in v0.6.1
func (jh *JsonHelper) ToFile() *JsonHelper
func (*JsonHelper) ToJson ¶ added in v0.6.1
func (jh *JsonHelper) ToJson() (string, error)
ToJson Deprecated: 请使用 JsonHelper.ToString
func (*JsonHelper) ToMap ¶ added in v0.6.1
func (jh *JsonHelper) ToMap(newMap *map[string]interface{}) *JsonHelper
func (*JsonHelper) ToString ¶ added in v0.6.1
func (jh *JsonHelper) ToString(newStr *string) *JsonHelper
func (*JsonHelper) ToStruct ¶ added in v0.6.1
func (jh *JsonHelper) ToStruct(newStruct interface{}) *JsonHelper
type MapHelper ¶ added in v0.6.1
func SetMapStrInterface ¶ added in v0.1.2
SetMapStrInterface Deprecated: 请使用 NewMap
func (*MapHelper) ArrayValues ¶ added in v0.6.1
func (d *MapHelper) ArrayValues() []interface{}