interfaceKit

package
v3.0.923 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNotNil

func AssertNotNil(obj interface{}, name string) error

func GetZeroValue

func GetZeroValue[T any]() T

GetZeroValue 获取类型T的零值.

func IsNil

func IsNil(obj interface{}) bool

IsNil Deprecated: 反射有性能问题,应尽可能避免使用此方法.

go里面的类型包含 type 和 value 的,一般对于业务我们更在意value是不是空.

e.g.

var src interface{} = nil
var src1 []string = nil
var src2 map[string]interface{} = nil
type bean struct {
}
var src3 *bean = nil

fmt.Println(interfaceKit.IsNil(src))  // true
fmt.Println(interfaceKit.IsNil(src1)) // true
fmt.Println(interfaceKit.IsNil(src2)) // true
fmt.Println(interfaceKit.IsNil(src3)) // true

func IsZeroValue

func IsZeroValue[T comparable](v T) bool

IsZeroValue 传参v是否是类型T的零值?

e.g. [interface{}](nil) => true

Types

This section is empty.

Jump to

Keyboard shortcuts

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