SpringUtils

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 15 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BASE64 added in v1.0.4

func BASE64(str string) string

BASE64 返回 BASE64 加密后的字符串

func ContainsInt added in v1.0.4

func ContainsInt(array []int, val int) int

ContainsInt 在一个 int 数组中进行查找,找不到返回 -1。

func ContainsString added in v1.0.4

func ContainsString(array []string, val string) int

ContainsString 在一个 string 数组中进行查找,找不到返回 -1。

func CopyBeanUseJson

func CopyBeanUseJson(src interface{}, dest interface{}) error

CopyBeanUseJson 使用 json 序列化框架进行拷贝,支持匿名字段,支持类型转换。

func CurrentMilliSeconds added in v1.0.4

func CurrentMilliSeconds() int64

CurrentMilliSeconds 返回当前的毫秒时间戳

func DefaultBool added in v1.0.3

func DefaultBool(v interface{}) (bool, bool)

DefaultBool 将 nil 转换成 false 布尔值

func DefaultString added in v1.0.3

func DefaultString(v interface{}) (string, bool)

DefaultString 将 nil 转换成空字符串

func EqualsIgnoreCase deprecated added in v1.0.4

func EqualsIgnoreCase(a, b string) bool

Deprecated: Use "strings.EqualFold" instead.

func ErrorToString added in v1.0.4

func ErrorToString(err error) string

ErrorToString 获取 error 的字符串

func ErrorWithFileLine added in v1.0.4

func ErrorWithFileLine(err error) error

ErrorWithFileLine 返回错误发生的文件行号

func FileLine added in v1.0.4

func FileLine(fn interface{}) (file string, line int, fnName string)

FileLine 获取函数所在文件、行数以及函数名

func FindInList added in v1.0.4

func FindInList(v interface{}, l *list.List) (*list.Element, bool)

FindInList 查询列表中是否存在指定元素,存在则返回列表项指针

func Indirect added in v1.0.3

func Indirect(t reflect.Type) reflect.Type

Indirect 解除 Type 的指针

func IsNil added in v1.0.4

func IsNil(v reflect.Value) bool

IsNil 返回 reflect.Value 的值是否为 nil,比原生方法更安全

func LocalIPv4

func LocalIPv4() string

LocalIPv4 获取本机的 IPv4 地址

func MD5 added in v1.0.4

func MD5(str string) string

MD5 获取 MD5 计算后的字符串

func MilliSeconds added in v1.0.4

func MilliSeconds(d time.Duration) int64

MilliSeconds 返回 Duration 对应的毫秒时间

func NewList

func NewList(v ...interface{}) *list.List

NewList 使用指定的元素创建列表

func SafeCloseChan

func SafeCloseChan(ch chan struct{})

SafeCloseChan 安全地关闭一个管道

func ToInt16SliceE added in v1.0.4

func ToInt16SliceE(i interface{}) ([]int16, error)

ToInt16SliceE casts an interface to a []int16 type.

func ToInt32SliceE added in v1.0.4

func ToInt32SliceE(i interface{}) ([]int32, error)

ToInt32SliceE casts an interface to a []int32 type.

func ToInt64SliceE added in v1.0.4

func ToInt64SliceE(i interface{}) ([]int64, error)

ToInt64SliceE casts an interface to a []int64 type.

func ToInt8SliceE added in v1.0.4

func ToInt8SliceE(i interface{}) ([]int8, error)

ToInt8SliceE casts an interface to a []int8 type.

func ToIntSliceE added in v1.0.4

func ToIntSliceE(i interface{}) ([]int, error)

ToIntSliceE casts an interface to a []int type.

func ToJson

func ToJson(i interface{}) string

ToJson 对象转 Json 字符串

func ToUint16SliceE added in v1.0.4

func ToUint16SliceE(i interface{}) ([]uint16, error)

ToUint16SliceE casts an interface to a []uint16 type.

func ToUint32SliceE added in v1.0.4

func ToUint32SliceE(i interface{}) ([]uint32, error)

ToUint32SliceE casts an interface to a []uint32 type.

func ToUint64SliceE added in v1.0.4

func ToUint64SliceE(i interface{}) ([]uint64, error)

ToUint64SliceE casts an interface to a []uint64 type.

func ToUint8SliceE added in v1.0.4

func ToUint8SliceE(i interface{}) ([]uint8, error)

ToUint8SliceE casts an interface to a []uint8 type.

func ToUintSliceE added in v1.0.4

func ToUintSliceE(i interface{}) ([]uint, error)

ToUintSliceE casts an interface to a []uint type.

func ValuePatch

func ValuePatch(v reflect.Value) reflect.Value

ValuePatch 开放 Value 的私有字段,但是不会更新外部传入的 Value。

func ValuePatchIf

func ValuePatchIf(v reflect.Value, allAccess bool) reflect.Value

ValuePatchIf allAccess 为 true 时开放 Value 的私有字段,但是不会更新外部传入的 Value。

Types

type PanicCond

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

PanicCond 封装触发 panic 的条件

func NewPanicCond

func NewPanicCond(e interface{}) *PanicCond

NewPanicCond PanicCond 的构造函数

func Panic

func Panic(err error) *PanicCond

Panic 返回一个封装的 panic 条件

func (*PanicCond) When

func (p *PanicCond) When(isPanic bool)

When 满足给定条件时抛出一个 panic

type WaitGroup added in v1.0.4

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

WaitGroup 封装 sync.WaitGroup,提供更简单的 API

func (*WaitGroup) Add added in v1.0.4

func (wg *WaitGroup) Add(fn func())

Add 添加一个非阻塞的任务,任务在新的 Go 程执行

func (*WaitGroup) Wait added in v1.0.4

func (wg *WaitGroup) Wait()

Wait 等待所有任务执行完成

Jump to

Keyboard shortcuts

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