env

package module
v0.0.0-...-e7cd1cc Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvSource

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

DO NOT CREATE INSTANCES MANUALLY, THIS IS ONLY PUBLIC IN ORDER FOR GODOC TO RENDER AVAILABLE FUNCTIONS.

func Source

func Source() *EnvSource

Source creates a source for environment variables of the current process.

func (*EnvSource) KeyJoiner

func (s *EnvSource) KeyJoiner(keyJoiner func(string, string) string) *EnvSource

KeyJoiner defines the function that builds the environment variable keys. For example consider the following struct:

type Config struct {
    Sub struct {
        Field int `key:"field"`
    } `key:"sub"`
}

The joiner could for example produce SUB_FIELD or subField, depending on what the programmer desires. By default this function is set to uppercase and connecting with underscores, preventing duplicate underscores.

func (*EnvSource) KeyTag

func (s *EnvSource) KeyTag() string

KeyTag implements Source.Key.

func (*EnvSource) KeyValueConverter

func (s *EnvSource) KeyValueConverter(keyValueConverter func(string) string) *EnvSource

KeyValueConverter defines how the yagcl.DefaultKeyTagName value should be converted for this source. If you are setting this, you'll most liekly also have to set EnvSource.KeyJoiner(string,string) string. Note that calling this isn't required, as there's a best practise default behaviour.

func (*EnvSource) Parse

func (s *EnvSource) Parse(configurationStruct any) (bool, error)

Parse implements Source.Parse.

func (*EnvSource) Prefix

func (s *EnvSource) Prefix(prefix string) *EnvSource

Prefix specified the prefixes expected in environment variable keys. For example "PREFIX_FIELD_NAME".

Jump to

Keyboard shortcuts

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