common

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotStruct = errors.New("destination must by struct or a pointer to struct")
)

UpdateStructFields() errors

Functions

func FindInIntgArray

func FindInIntgArray(elem int64, a []int64) (e int64, found bool)

FindInIntgArray searches for the indicated element 'elem' in array 'a'

func FindInStringArray

func FindInStringArray(elem string, a []string) (e string, found bool)

FindInStringArray searches for the indicated element 'elem' in array 'a'

func GetNonNullFields

func GetNonNullFields(i interface{}, tagName string) (fields []string)

GetNonNullFields returns an array with all the fields that aren't nil in the structure's instance

func IsEmailAddress

func IsEmailAddress(str string) bool

IsEmailAddress returns true if str seems to be an email address

func MaskString

func MaskString(s string, noMaskLeft, noMaskRight int, maskChar string) (masked string)

MaskString creates a mask with `maskChar` for the indicated string `s`. If noMaskLeft and noMaskRight equals -1, then all the string is masked.

func Random

func Random(min, max int) int

Random generates a random number between min and max.

func RandomString

func RandomString(n int) string

RandomString generates a random string of the specified length. Keep in mind that random seed must be initialized before. Example:

rand.Seed(time.Now().Unix())

func UpdateStructFromMap

func UpdateStructFromMap(destination interface{}, source map[string]interface{}) (err error)

UpdateStructFromMap can be used to update the fields of a structure by sending the new field values in a map, wherer the key is the field name as in the struct and the value is the new value that will be set.

Only those values in the map will be evaluated and updated. Parameter destination must be a pointer, otherwise changes won't be reflected.

Types

This section is empty.

Jump to

Keyboard shortcuts

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