config

package
v0.1.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONDecoder

func JSONDecoder(raw []byte, into any) error

func Load

func Load(into any, loaders ...TryLoader) error

Load attempts to get the configuration from the provided loader(s). It returns an error if all loaders fail.

func MustLoad

func MustLoad(into any, loaders ...TryLoader)

MustLoad is like Load but panics if all loaders fail.

Types

type Decoder

type Decoder func(raw []byte, into any) error

Decoder is used to decode the data in loaded from a file. For example: json.Unmarshal implements this interface.

type TryLoader

type TryLoader func(into any) error

TryLoader is used to load configuration from a file or an environment variable for example.

func TryLoadFile

func TryLoadFile(fpath string, decoder Decoder) TryLoader

func TryLoadString

func TryLoadString(s string, decoder Decoder) TryLoader

Jump to

Keyboard shortcuts

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