defaults

package
v8.12.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetStructValues

func SetStructValues(target interface{}) error

SetStructValues sets struct field default values defined in `default` tags.

func SetValues

func SetValues(target interface{}) (err error)

SetValues sets default values for an object if it implements the Defaulter interface. Objects that do not implement the defaulter interface are not modified.

Types

type Defaulter

type Defaulter interface {
	// SetDefaults sets the object's default values. This method must modify the object.
	SetDefaults() error
}

Defaulter allows defining default values for an object. Note that because the methods in this interface directly modify an object's properties, it should only be implemented by objects that support pointer receivers.

Jump to

Keyboard shortcuts

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