structs

package
v7.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFieldNotFound is returned when an operation is unable to find a target field.
	ErrFieldNotFound = errors.New("struct field not found")
)

Functions

func GetFieldTagValue

func GetFieldTagValue(targetStruct interface{}, fieldName string, tagName string) (string, error)

GetFieldTagValue gets a tag value from a struct field. The tag is always returned as a string, independent of field type.

Example ```

s := Struct{
    Value int `default:"100" validate:"required"`
}{}

// Get the Value field default value tag := GetFieldTagValue(s, "Value", "default")

// Prints 100 fmt.Println(tag) ```

Types

This section is empty.

Jump to

Keyboard shortcuts

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