Documentation
¶
Overview ¶
Package default applies default values to struct fields at their zero value.
Example:
type User struct { Name string `default:"Goku"` Power float64 `default:"9000.1"` } u := User{Name: "Carrot"} err := defaults.Apply(&u) if err != nil { log.Fatal("Uh oh: %v", err) } fmt.Print(u.Name) // Carrot fmt.Print(u.Power) // 9000.1
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrNotAStructPointer ¶
type ErrNotAStructPointer string
ErrNotAStructPointer indicates that we were expecting a pointer to a struct, but got something else.
func (ErrNotAStructPointer) Error ¶
func (e ErrNotAStructPointer) Error() string
Error implements the error interface.
type ErrorUnsettable ¶
type ErrorUnsettable string
ErrorUnsettable is used when a field cannot be set.
func (ErrorUnsettable) Error ¶
func (e ErrorUnsettable) Error() string
Error implements the error interface.
type ErrorUnsupportedType ¶
type ErrorUnsupportedType struct {
// contains filtered or unexported fields
}
ErrorUnsupportedType indicates that the type of the struct field is not yet support in this package.
func (ErrorUnsupportedType) Error ¶
func (e ErrorUnsupportedType) Error() string
Error implements the error interface.
Click to show internal directories.
Click to hide internal directories.