gstruct

package
v0.0.0-...-04ff805 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(a, b interface{}) (bool, error)

compare map / structures ...

func HasZero

func HasZero(x interface{}) bool

Check if any field of a struct is initialized or not.

func IsStruct

func IsStruct(x interface{}) bool

Check if server is a struct or a pointer to struct

func IsZero

func IsZero(x interface{}) bool

Check if all fields of a struct is initialized or not.

func Iterate

func Iterate(toModify interface{}, tagKey, tagVal string, iterFn IterateFn) error

Iterate over the basic type members of a structure with a specific flag. Reference: https://github.com/IQ-tech/go-crypto-layer/blob/master/datacrypto/aesecb.go#L42 EncryptStruct crawls all annotated struct properties and encrypts them in place

func MemberNames

func MemberNames(x interface{}) []string

Convert the names of a struct to a []string (see "Names methods" for more info about fields)

func MemberValues

func MemberValues(x interface{}) []interface{}

func Members

func Members(x interface{}) []*structs.Field

Convert the values of a struct to a []*Field (see "Field methods" for more info about fields)

func StructName

func StructName(x interface{}) string

Return the struct name => "Server"

func StructPack

func StructPack(v interface{}, p []byte) error

func StructUnpack

func StructUnpack(p []byte, v interface{}) error

func ToMap

func ToMap(x interface{}) map[string]interface{}

Convert a struct to a map[string]interface{} => {"Name":"gopher", "ID":123456, "Enabled":true}

Types

type IterateFn

type IterateFn = func(v reflect.Value) (newVal reflect.Value, modified bool, err error)

Jump to

Keyboard shortcuts

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