defaults

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package default allows users to initialize structs with default values as defined in struct tags. The default values are parsed from the struct tag string in the same way that environment variables from the confire env package are parsed.

Index

Constants

This section is empty.

Variables

View Source
var SetDefaults func(spec interface{}) error = Process

SetDefaults is an alias of Process

Functions

func MustProcess

func MustProcess(spec interface{})

MustProcess is the same as Process but panics if an error occurs

func Process

func Process(spec interface{}) (err error)

Process a struct to add the defaults from the default struct tag, parsing the struct tag string into the correct type using the same methodology as processing environment variables. Most types are parsed using the strconv package (time.Duration is handled specially). If the type implements Decoder, Setter, TextUnmarshaler, or BinaryUnmarshaler, then those decoders are used to parse the default value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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