env

package
v0.0.0-...-9679412 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Overview

Package env implements a koanf.Provider that reads environment variables as conf maps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

type Env struct {
	// contains filtered or unexported fields
}

Env implements an environment variables provider.

func Provider

func Provider(prefix, delim string, cb func(s string) string) *Env

Provider returns an environment variables provider that returns a nested map[string]interface{} of environment variable where the nesting hierarchy of keys are defined by delim. For instance, the delim "." will convert the key `parent.child.key: 1` to `{parent: {child: {key: 1}}}`.

If prefix is specified (case sensitive), only the env vars with the prefix are captured. cb is an optional callback that takes a string and returns a string (the env variable name) in case transformatios have to be applied, for instance, to lowercase everything, strip prefixes and replace _ with . etc.

func (*Env) Read

func (e *Env) Read() (map[string]interface{}, error)

Read reads all available environment variables into a key:value map and returns it.

func (*Env) ReadBytes

func (e *Env) ReadBytes() ([]byte, error)

ReadBytes is not supported by the env provider.

func (*Env) Watch

func (e *Env) Watch(cb func(event interface{}, err error)) error

Watch is not supported.

Jump to

Keyboard shortcuts

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