Documentation
¶
Index ¶
- Variables
- type Primordius
- func (pr *Primordius) AddSource(s Source)
- func (pr *Primordius) FromEnv(prefix string)
- func (pr *Primordius) FromJSON(content []byte)
- func (pr *Primordius) FromJSONFile(name string)
- func (pr *Primordius) FromJSONReader(r io.Reader)
- func (pr *Primordius) FromTOML(content []byte)
- func (pr *Primordius) FromTOMLFile(name string)
- func (pr *Primordius) FromTOMLReader(r io.Reader)
- func (pr *Primordius) FromYAML(content []byte)
- func (pr *Primordius) FromYAMLFile(name string)
- func (pr *Primordius) FromYAMLReader(r io.Reader)
- func (pr *Primordius) Process() error
- func (pr *Primordius) ResetSources()
- type Source
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSpecification = errors.New("specification must be a struct pointer")
Functions ¶
This section is empty.
Types ¶
type Primordius ¶
type Primordius struct {
// contains filtered or unexported fields
}
Primordius manages sources and processes them into the set target.
func New ¶
func New(target any) *Primordius
New allocates and returns a new instance of Primordius with the supplied target. target MUST be a pointer to a struct.
func (*Primordius) AddSource ¶
func (pr *Primordius) AddSource(s Source)
AddSource adds a Source s to pr to obtain arbitrary configuration values from. Can also be used to add a custom Source.
func (*Primordius) FromEnv ¶
func (pr *Primordius) FromEnv(prefix string)
FromEnv adds a Source to pr which reads values from environment variables.
func (*Primordius) FromJSON ¶
func (pr *Primordius) FromJSON(content []byte)
FromJSON adds a Source to pr which reads values from a JSON block.
func (*Primordius) FromJSONFile ¶
func (pr *Primordius) FromJSONFile(name string)
FromJSONFile adds a Source to pr which reads values from a JSON file.
func (*Primordius) FromJSONReader ¶
func (pr *Primordius) FromJSONReader(r io.Reader)
FromJSONReader adds a Source to pr which reads YAML content from r.
func (*Primordius) FromTOML ¶
func (pr *Primordius) FromTOML(content []byte)
func (*Primordius) FromTOMLFile ¶
func (pr *Primordius) FromTOMLFile(name string)
func (*Primordius) FromTOMLReader ¶
func (pr *Primordius) FromTOMLReader(r io.Reader)
func (*Primordius) FromYAML ¶
func (pr *Primordius) FromYAML(content []byte)
FromYAML adds a Source to pr which reads values from a YAML block.
func (*Primordius) FromYAMLFile ¶
func (pr *Primordius) FromYAMLFile(name string)
FromYAMLFile adds a Source to pr which reads values from a YAML file.
func (*Primordius) FromYAMLReader ¶
func (pr *Primordius) FromYAMLReader(r io.Reader)
FromYAMLReader adds a Source to pr which reads JSON content from r.
func (*Primordius) Process ¶
func (pr *Primordius) Process() error
Process calls all registered Sources to write values into pr.target. Registered sources are processed in the order they were initially added.
func (*Primordius) ResetSources ¶
func (pr *Primordius) ResetSources()
ResetSources empties the internal list of registered Sources.