Documentation
¶
Index ¶
- Constants
- func Bool(path string) (bool, error)
- func BoolMustResolve(path string) bool
- func Duration(path string) (time.Duration, error)
- func DurationMustResolve(path string) time.Duration
- func Float(path string) (float64, error)
- func FloatMustResolve(path string) float64
- func HasPath(path string) (bool, error)
- func Int(path string) (int, error)
- func IntMustResolve(path string) int
- func Load(options ...func(*Option)) error
- func Multiaddr(path string) (multiaddr.Multiaddr, error)
- func MultiaddrMustResolve(path string) multiaddr.Multiaddr
- func Set(path string, value string) (bool, error)
- func Size(path string) (int64, error)
- func SizeMustResolve(path string) int64
- func String() string
- func Time(path string) (time.Time, error)
- func TimeMustResolve(path string) time.Time
- func URL(path string) (*url.URL, error)
- func URLMustResolve(path string) *url.URL
- func Value(path string) (string, error)
- func ValueMustResolve(path string) string
- func ValuesMustResolve(path string) []string
- func WithFilePath(filePath string) func(*Option)
- type Option
- type Path
- type PathError
Constants ¶
const ( ErrNotInitialized = configErr("not initialized") ErrPathNotFound = configErr("path not found") )
Enumeration of errors that may be returned by configuration operations.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool retrieves the boolean value for the provided path.
The returned error will be non-nil if the value corresponding to the provided path:
- could not be found
- was found, but could not be parsed as a boolean
func BoolMustResolve ¶
BoolMustResolve is similar behavior to Bool, but panics if an error occurs.
func Duration ¶
Duration retrieves the time.Duration value for the provided path.
The returned error will be non-nil if the value corresponding to the provided path:
- could not be found
- was found, but could not be parsed as a Duration
func DurationMustResolve ¶
DurationMustResolve is similar behavior to Duration, but panics if an error occurs.
func Float ¶
Float retrieves the float value for the provided path.
The returned error will be non-nil and the returned float value will be set to 0 if the value corresponding to the provided path:
- could not be found
- was found, but could not be parsed as a float
func FloatMustResolve ¶
FloatMustResolve is similar behavior to Float, but panics if an error occurs.
func Int ¶
Int retrieves the integer value for the provided path.
The returned error will be non-nil and the returned integer value will be set to 0 if the value corresponding to the provided path:
- could not be found
- was found, but could not be parsed as an integer
func IntMustResolve ¶
IntMustResolve is similar behavior to Int, but panics if an error occurs.
func Load ¶
Load reads and parses the configuration using the provided optional properties.
If an error occurs during read/parse operations, error will be non-nil.
func Multiaddr ¶
Multiaddr retrieves the multiaddr.Multiaddr value for the provided path.
The returned error will be non-nil if the value corresponding to the provided path:
- could not be found
- was found, but could not be parsed as a multiaddr.Multiaddr value
func MultiaddrMustResolve ¶
func MultiaddrMustResolve(path string) multiaddr.Multiaddr
MultiaddrMustResolve is similar in behavior to Multiaddr, but panics if an error occurs.
func Set ¶
Set sets or replaces a configuration value for the provided path.
Returns:
- true if the value corresponding to the provided path was successfully replaced
- false if the configuration does not contain the specified path or otherwise could not replace the value
func Size ¶
Size retrieves the size value for the provided path.
The returned error will be non-nil if the value corresponding to the provided path:
- could not be found
- was found, but could not be parsed as a size value
func SizeMustResolve ¶
SizeMustResolve is similar behavior to Size, but panics if an error occurs.
func Time ¶
Time retrieves the time value for the provided path.
The returned error will be non-nil if the value corresponding to the provided path:
- could not be found
- was found, but could not be parsed as a time.Time value
func TimeMustResolve ¶
TimeMustResolve is similar behavior to Time, but panics if an error occurs.
func URL ¶
URL retrieves the url.URL value for the provided path.
The returned error will be non-nil if the value corresponding to the provided path:
- could not be found
- was found, but could not be parsed as a url.URL value
func URLMustResolve ¶
URLMustResolve is similar in behavior to URL, but panics if an error occurs.
func Value ¶
Value retrieves the value for the provided path.
The returned error will be non-nil if:
- the configuration has not been initialized
- the value corresponding to the provided path could not be found
func ValueMustResolve ¶
ValueMustResolve is similar behavior to Value, but panics if an error occurs.
func ValuesMustResolve ¶
ValuesMustResolve is similar behavior to values, but panics if an error occurs.
func WithFilePath ¶
WithFilePath sets the file path Option for the configuration. If the file path is not provided, the root of the project directory will be used for loading the configuration.
Types ¶
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option is a container for optional properties that can be used for initializing the configuration.
type Path ¶
type Path string
Path represents a Configuration path.
func (Path) Base ¶
Base returns last path element for the Configuration Path. For example, if Path.String returns `foo.bar.gopher`, then Base would return `gopher`.
func (Path) MarshalText ¶
MarshalText implements encoding.TextMarshaler for the Path.