SpringUtils

package
v1.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBean

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

CopyBean 使用反射直接赋值的方式拷贝,不支持匿名字段,不支持类型转换。 TODO 完善该方法,可以参考 json 序列化,并且需要进行性能测试。

func CopyBeanUseJson

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

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

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 Indirect added in v1.0.3

func Indirect(t reflect.Type) reflect.Type

Indirect 解除 Type 的指针

func LoadXmlConfig

func LoadXmlConfig(path string, config interface{}) error

LoadXmlConfig 加载 XML 配置文件

func LocalIPv4

func LocalIPv4() string

LocalIPv4 获取本机的 IPv4 地址

func NewList

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

func SafeCloseChan

func SafeCloseChan(ch chan struct{})

SafeCloseChan 安全地关闭一个管道

func ToJson

func ToJson(i interface{}) string

func ToString

func ToString(err error) string

ToString 获取 error 的字符串

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

Jump to

Keyboard shortcuts

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