Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
type Bool struct {
// contains filtered or unexported fields
}
Bool is a configuration value that is a bool.
type Config ¶
type Config interface { // NewInt creates a new int variable. NewInt(name string, defaultValue int, description string, options ...IntOption) error // Int returns the value of the int variable with the given name. If the variable does not exist, it calls bug.Bug. // If bug.Bug does not panic, Int returns 0. Int(name string) int // DescribeInt returns the description of the int variable with the given name. If the variable does not exist, it calls bug.Bug. // If bug.Bug does not panic, DescribeInt returns "". DescribeInt(name string) string // NewString creates a new string variable. NewString(name string, defaultValue string, description string, options ...StringOption) error // String returns the value of the string variable with the given name. If the variable does not exist, it calls bug.Bug. // If bug.Bug does not panic, String returns "". String(name string) string // DescribeString returns the description of the string variable with the given name. If the variable does not exist, it calls bug.Bug. // If bug.Bug does not panic, DescribeString returns "". DescribeString(name string) string // NewBool creates a new bool variable. NewBool(name string, defaultValue bool, description string) error // Bool returns the value of the bool variable with the given name. If the variable does not exist, it calls bug.Bug. // If bug.Bug does not panic, Bool returns false. Bool(name string) bool // DescribeBool returns the description of the bool variable with the given name. If the variable does not exist, it calls bug.Bug. // If bug.Bug does not panic, DescribeBool returns "". DescribeBool(name string) string }
Config holds configuration variables.
type Int ¶
type Int struct {
// contains filtered or unexported fields
}
Int is a configuration value that is an integer.
type IntOption ¶
IntOption is an option for an int variable.
func WithClamping ¶
func WithClamping() IntOption
WithClamping returns an option that enables clamping for an int variable.
func WithIntValidator ¶
WithIntValidator returns an option that sets the validator for an int variable.
func WithMaximumValue ¶
WithMaximumValue returns an option that sets the maximum value for an int variable.
func WithMinimumValue ¶
WithMinimumValue returns an option that sets the minimum value for an int variable.
type Option ¶
type Option func(c *configImpl)
Option is an option for Config.
func WithLoadPrefix ¶
WithLoadPrefix returns an Option that prepends a prefix to the names of the configuration variables when loading them.
func WithSource ¶
WithSource returns an Option that sets the source of the configuration variables.
type Source ¶
type Source interface { // SetPrefix sets the prefix of the names of the configuration variables. SetPrefix(prefix string) // LoadInt loads the value of the int variable with the given name. If the // variable does not exist, it must return 0 and status.ErrNotFound. LoadInt(name string) (int, error) // LoadString loads the value of the string variable with the given name. If // the variable does not exist, it must return "" and status.ErrNotFound. LoadString(name string) (string, error) // LoadBool loads the value of the bool variable with the given name. If the // variable does not exist, it must return false and status.ErrNotFound. LoadBool(name string) (bool, error) }
Source is an interface that loads the values of the configuration variables.
type String ¶
type String struct {
// contains filtered or unexported fields
}
String is a configuration value that is a string.
type StringOption ¶
StringOption is an option for a string variable.
func WithStringValidator ¶
func WithStringValidator(f func(string) error) StringOption
WithStringValidator returns an option that sets the validator for a string variable.