utils

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: LGPL-3.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultDirMode  = 0o755
	DefaultFileMode = 0o644
)

Variables

This section is empty.

Functions

func ConcatWith

func ConcatWith(master, slave string) string

ConcatWith 用:号连接两个部分,如果后一部分也存在的话

func DeepCopy added in v1.6.0

func DeepCopy(dest, src any) (err error)

DeepCopy 深度复制对象

func FileSize

func FileSize(path string) (int64, bool)

FileSize 检查文件是否存在及大小 -1, false 不合法的路径 0, false 路径不存在 -1, true 存在文件夹 >=0, true 文件并存在

func JsonInt64 added in v1.6.1

func JsonInt64(val any) int64

JsonInt64 将被json解码为float64转回整数

func MarshalJSON added in v1.6.1

func MarshalJSON[T any](value T, valid bool) ([]byte, error)

MarshalJSON json编码

func MkdirForFile

func MkdirForFile(path string) int64

MkdirForFile 为文件路径创建目录

func Obj2Dict added in v1.6.1

func Obj2Dict(obj any) (map[string]any, error)

Obj2Dict 将对象转为map格式

func PrintJson added in v1.6.0

func PrintJson(data any) (err error)

PrintJson 以JSON格式输出数据

func StrToList

func StrToList(data []string) []any

StrToList 将字符串数组转为一般数组

func UnmarshalJSON added in v1.6.1

func UnmarshalJSON[T any](data []byte, value *T) (bool, error)

UnmarshalJSON json解码

func WrapWith

func WrapWith(s, left, right string) string

WrapWith 如果本身不为空,在左右两边添加字符

Types

type NullFloat64 added in v1.6.1

type NullFloat64 struct {
	sql.NullFloat64
}

NullFloat64 可空浮点数

func (*NullFloat64) MarshalJSON added in v1.6.1

func (v *NullFloat64) MarshalJSON() ([]byte, error)

func (*NullFloat64) UnmarshalJSON added in v1.6.1

func (v *NullFloat64) UnmarshalJSON(data []byte) (err error)

type NullInt64 added in v1.6.1

type NullInt64 struct {
	sql.NullInt64
}

NullInt64 可为空整数

func (*NullInt64) MarshalJSON added in v1.6.1

func (v *NullInt64) MarshalJSON() ([]byte, error)

func (*NullInt64) UnmarshalJSON added in v1.6.1

func (v *NullInt64) UnmarshalJSON(data []byte) (err error)

type NullString added in v1.6.1

type NullString struct {
	sql.NullString
}

NullString 可空字符串

func (*NullString) MarshalJSON added in v1.6.1

func (v *NullString) MarshalJSON() ([]byte, error)

func (*NullString) UnmarshalJSON added in v1.6.1

func (v *NullString) UnmarshalJSON(data []byte) (err error)

type NullTime added in v1.6.1

type NullTime struct {
	sql.NullTime
}

NullTime 可为空时间

func (*NullTime) MarshalJSON added in v1.6.1

func (v *NullTime) MarshalJSON() ([]byte, error)

func (*NullTime) UnmarshalJSON added in v1.6.1

func (v *NullTime) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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