util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldWithJsonTagValue

func FieldWithJsonTagValue(model interface{}, value string) (name string, ok bool)

FieldWithJsonTagValue returns the first field with a specific JSON tag. It parses the JSON tag to match against the primary key in the json tag, unwinding custom json tag options. See documentation at https://golang.ir/pkg/encoding/json/#Marshal

func GetFieldByName

func GetFieldByName(structPtr interface{}, fieldName string) reflect.Value

GetFieldByName gets the value of a field on the given structPtr.

func InterfaceSlice

func InterfaceSlice(slice interface{}) []interface{}

InterfaceSlice takes an interface representing a known slice, and converts it into a []interface{}.

func IsBlank

func IsBlank(s string) bool

func LookupForStructFieldTag

func LookupForStructFieldTag(model interface{}, field string, tagName string) (value string, ok bool)

LookupForStructFieldTag returns the string value associated with a field and tag in a model, if it exists.

func StructValueAndType

func StructValueAndType(model interface{}) (reflect.Value, reflect.Type)

StructValueAndType returns a the reflected value and type of a model.

func ValuesForStructTag

func ValuesForStructTag(model interface{}, tagName string) []string

ValuesForStructTag returns a list of string values associated with a tag in a model.

Types

This section is empty.

Jump to

Keyboard shortcuts

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