reflectKit

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package reflectKit Default将默认值应用于零值的struct字段。 本文件引用zzjcool/goutils项目,引用地址为:https://github.com/zzjcool/goutils/blob/main/defaults/defauls.go

Package reflectKit 主要用于生成一个Record

Package reflectKit 反射工具包

Index

Constants

View Source
const (
	StateOk   = true
	StateFail = false
)

Variables

This section is empty.

Functions

func StructDefault

func StructDefault(t interface{}) error

StructDefault 给结构体增加默认值 *

  • @param t 结构体
  • @return 返回错误信息

func StructToMapSI added in v0.0.8

func StructToMapSI(v interface{}) map[string]interface{}

StructToMapSI 结构体转换为map[string]interface *

  • @param body 待转换的结构体
  • @return map[string]interface

func StructToMapSS added in v0.0.8

func StructToMapSS(body interface{}) map[string]string

StructToMapSS 结构体转换为map[string]string *

  • @param body 待转换的结构体
  • @return map[string]string

Types

type ErrNotAStructPointer

type ErrNotAStructPointer string

ErrNotAStructPointer 一个指向struct的指针,

func (ErrNotAStructPointer) Error

func (e ErrNotAStructPointer) Error() string

Error 实现错误接口

type ErrorUnsettable

type ErrorUnsettable string

ErrorUnsettable 当不能设置字段时使用

func (ErrorUnsettable) Error

func (e ErrorUnsettable) Error() string

Error 实现错误接口

type ErrorUnsupportedType

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

ErrorUnsupportedType 指示结构字段的类型还不是此包中的支持

func (ErrorUnsupportedType) Error

func (e ErrorUnsupportedType) Error() string

Error 实现错误接口

type Record

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

func (*Record) Get added in v0.1.1

func (r *Record) Get(column string) interface{}

Get 查询记录中指定字段的值

func (*Record) Remove added in v0.1.1

func (r *Record) Remove(column string)

Remove 删除记录中指定字段

func (*Record) Set added in v0.1.1

func (r *Record) Set(column string, value interface{})

Set 修改记录中指定字段的值

func (*Record) ToJSON added in v0.1.1

func (r *Record) ToJSON() (string, error)

ToJSON 将记录转换为 JSON 格式的字符串

type Ret added in v0.1.1

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

func (*Ret) By added in v0.1.1

func (r *Ret) By(key string, value interface{}) *Ret

By 设置返回的数据为 key-value 对

func (*Ret) Delete added in v0.1.1

func (r *Ret) Delete(key string) *Ret

Delete 删除返回的数据

func (*Ret) Fail added in v0.1.1

func (r *Ret) Fail() *Ret

Fail 设置返回的数据为失败状态

func (*Ret) Get added in v0.1.1

func (r *Ret) Get(key string) interface{}

Get 获取返回的数据

func (*Ret) IsOk added in v0.1.1

func (r *Ret) IsOk() bool

IsOk 获取返回的数据是否正确

func (*Ret) Ok added in v0.1.1

func (r *Ret) Ok() *Ret

Ok 设置返回的数据为成功状态

func (*Ret) Set added in v0.1.1

func (r *Ret) Set(key string, value interface{}) *Ret

Set 设置返回的数据

func (*Ret) ToJSON added in v0.1.1

func (r *Ret) ToJSON() (string, error)

ToJSON 将 Ret 结构体转换为 JSON 格式的字符串

Jump to

Keyboard shortcuts

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