env

package
v0.0.0-...-93b1e75 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package env is a wrapper around config package and allows reading configuration from some source and parsing it with some encoder, both defined in environment variables.

Used environment variables: CONFIG_FILE - configuration file name. Default is 'configs/config.<encoder>'. CONFIG_ETCD_ENDPOINTS - etcd endpoints separated with comma. Such as '127.0.0.1:2379'. CONFIG_ETCD_KEY - key in etcd server where configuration data is stored. CONFIG_ENCODER - one of the supported encoders: json, yaml or toml. Default is 'yaml'.

Typical usage:

cfg := config.Must(env.NewConfig())

err = cfg.Get(&myStructure)
if err != nil {
    panic(err)
}

See config package for more details.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownEncoder = errors.New("unknown encoder")

ErrUnknownEncoder error is returned when encoder defined in environment variable CONFIG_ENCODER is unsupported.

Functions

func NewConfig

func NewConfig() (*config.Config, error)

NewConfig function creates new configuration service using source and encoder defined in environment variables. Use CONFIG_FILE to define configuration file. Default is 'configs/config.<encoder>'. Use CONFIG_ETCD_ENDPOINTS and CONFIG_ETCD_KEY to define etcd deployment as a source. Use CONFIG_ENCODER to define one of the supported encoders: json, yaml or toml. Default is 'yaml'.

Types

This section is empty.

Directories

Path Synopsis
Package etcd is a wrapper around config package and allows reading configuration from some key in etcd server and parsing it with some encoder, where endpoints and key are defined in environment variables.
Package etcd is a wrapper around config package and allows reading configuration from some key in etcd server and parsing it with some encoder, where endpoints and key are defined in environment variables.
Package file is a wrapper around config package and allows reading configuration from some file on disk and parsing it with some encoder, where file name is defined in environment variable.
Package file is a wrapper around config package and allows reading configuration from some file on disk and parsing it with some encoder, where file name is defined in environment variable.

Jump to

Keyboard shortcuts

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