diff

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEditAny

func IsEditAny(src interface{}, target interface{}, rule ...string) (string, bool, error)

IsEditAny 仅接受两个结构体互相校验,rule会默认匹配标签名,并自动匹配下划线/小驼峰/大驼峰;不支持未导出的 field,硬拿会报错

func IsIn

func IsIn(src interface{}, target interface{}, keys ...string) (bool, error)

func IsInMapIntInt

func IsInMapIntInt(a map[int]int, b int) bool

func Max

func Max(a, b int) int

func Min

func Min(a, b int) int

Types

type InterfaceResult

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

func NewDiff

func NewDiff(src, target interface{}, srcKey, targetKey string) (*InterfaceResult, error)

NewDiff

@Description: 接收到返回值后,需要自己断言一下,例如 xxx.([]int)
@param src 原始值,通常传数据库那一份即可
@param target 新的值,通常传 request 传进来的即可
@param keys 唯一判断 keys, 通常为 ID
@return interface{} added
@return interface{} update
@return interface{} deleted
@return error

func (*InterfaceResult) GetAdded

func (i *InterfaceResult) GetAdded() []interface{}

func (*InterfaceResult) GetDeleted

func (i *InterfaceResult) GetDeleted() []interface{}

func (*InterfaceResult) GetUpdated

func (i *InterfaceResult) GetUpdated() []interface{}

func (*InterfaceResult) ScanAdded

func (i *InterfaceResult) ScanAdded(pointer interface{}, mapping ...map[string]string) (err error)

func (*InterfaceResult) ScanDeleted

func (i *InterfaceResult) ScanDeleted(pointer interface{}, mapping ...map[string]string) (err error)

func (*InterfaceResult) ScanUpdated

func (i *InterfaceResult) ScanUpdated(pointer interface{}, mapping ...map[string]string) (err error)

Jump to

Keyboard shortcuts

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