package
0.5.1
Repository: https://github.com/warthog618/config.git
Documentation: pkg.go.dev

# README

blob

A library for loading configuration files into config.

GoDoc

Blobs represent configuration sources containing configuration stored as a block and in a known format, e.g. config files. Blobs are partitioned into two layers, the Loader, which loads the configuration as a []byte blob from the source, and the Decoder, which decodes the blob into a form that can be used by config.

The Loader may support being watched for changes, and if so the Blob containing it will automatically support being watched for changes as well.

Quick Start

Given a loader and decoder, you create a blob and add it to your config:

    c := config.New(blob.New(file.New("config.json"), json.NewDecoder()))

or add it into your config stack:

    c := config.New(pflag.New(), env.New())
    // ...
    cfgFile := blob.New(file.New("config.json"), json.NewDecoder())
    c.Append(cfgFile)

Loaders

Loaders read configuration from some source.

The following loaders are provided:

LoaderConfiguration Source
bytes[]byte
filelocal file

Decoders

Decoders unmarshal configuration from a particular textual format.

Decoders for the following formats are provided:

# Packages

Package decoder contains decoders that convert blobs of configuration from raw bytes into map[string]interface{}.
Package loader contains loaders that read blobs of configuration from various sources.

# Functions

MustLoad requires that the Blob successfully loads during construction.
New creates a new Blob using the provided loader and decoder.
NewConfigFile is a helper function that creates a File getter.
WithErrorHandler is an Option that sets the error handling for an object.
WithSeparator is an Option that sets the config namespace separator.

# Structs

ErrorHandlerOption defines the handler for errors returned during construction and the initial load.
Getter represents a two stage getter for blobs.
SeparatorOption defines the string that separates tiers in keys.

# Interfaces

Decoder unmarshals configuration from raw []byte into the provided type, typically a map[string]interface{}.
Loader retrieves raw configuration data, as []byte, from some source.
Option is a construction option for a Blob.
WatchableLoader is the interface supported by Loaders that can be watched for changes.

# Type aliases

ErrorHandler handles an error.