example

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Code generated by "envopts -type=FooEnv"; DO NOT EDIT.

Code generated by "envopts -type=fooEnv -optionType=PrivOption -output=private_foo_env.go"; DO NOT EDIT.

Code generated by "envopts -type=RabEnv -optionType=RabOption"; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunBar

func RunBar(be BarEnv)

Run make the warnings go away

Types

type BarEnv

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

BarEnv is one with a private field should result in nothing being generated

type FooEnv

type FooEnv struct {
	Home         string        `env:"HOME"`
	Port         int           `env:"PORT" envDefault:"3000"`
	Password     string        `env:"PASSWORD,unset"`
	IsProduction bool          `env:"PRODUCTION"`
	Hosts        []string      `env:"HOSTS" envSeparator:":"`
	Duration     time.Duration `env:"DURATION"`
	TempFolder   string        `env:"TEMP_FOLDER" envDefault:"${HOME}/tmp" envExpand:"true"`

	// test external package and one tag for multiple fields
	Foo, Dar []env.Options `env:"FOO"`
}

func ApplyOptions

func ApplyOptions(opts ...Option) (res FooEnv)

ApplyOptions will merge all options into the resulting FooEnv while also ensuring default values are always set.

type Option

type Option func(*FooEnv)

Option is a functional option to configure FooEnv

func FromFooEnv

func FromFooEnv(v *FooEnv) Option

FromFooEnv takes fully configured FooEnv and returns it as an option. Can be used to parse environment variables manually and provide the result in places where an option argument is expected.

func ParseEnv

func ParseEnv(eo env.Options) (opts []Option, err error)

ParseEnv will parse environment variables into a slice of options. Any options for parsing the environment can be supplied, for example to parse under a prefix.

func WithDar added in v0.2.2

func WithDar(v []env.Options) Option

WithDar configures FooEnv

func WithDuration

func WithDuration(v time.Duration) Option

WithDuration configures FooEnv

func WithFoo added in v0.2.2

func WithFoo(v []env.Options) Option

WithFoo configures FooEnv

func WithHome

func WithHome(v string) Option

WithHome configures FooEnv

func WithHosts

func WithHosts(v []string) Option

WithHosts configures FooEnv

func WithIsProduction

func WithIsProduction(v bool) Option

WithIsProduction configures FooEnv

func WithPassword

func WithPassword(v string) Option

WithPassword configures FooEnv

func WithPort

func WithPort(v int) Option

WithPort configures FooEnv

func WithTempFolder

func WithTempFolder(v string) Option

WithTempFolder configures FooEnv

type PrivOption

type PrivOption func(*fooEnv)

PrivOption is a functional option to configure fooEnv

func PrivOptionParseEnv

func PrivOptionParseEnv(eo env.Options) (opts []PrivOption, err error)

PrivOptionParseEnv will parse environment variables into a slice of options. Any options for parsing the environment can be supplied, for example to parse under a prefix.

func WithDurationPrivOption

func WithDurationPrivOption(v time.Duration) PrivOption

WithDurationPrivOption configures fooEnv

func WithHostsPrivOption

func WithHostsPrivOption(v []string) PrivOption

WithHostsPrivOption configures fooEnv

type RabEnv

type RabEnv struct {
	Home string `env:"HOME"` // User's home directory
}

func ApplyRabOptions

func ApplyRabOptions(opts ...RabOption) (res RabEnv)

ApplyRabOptions will merge all options into the resulting RabEnv while also ensuring default values are always set.

type RabOption

type RabOption func(*RabEnv)

RabOption is a functional option to configure RabEnv

func FromRabEnv

func FromRabEnv(v *RabEnv) RabOption

FromRabEnv takes fully configured RabEnv and returns it as an option. Can be used to parse environment variables manually and provide the result in places where an option argument is expected.

func RabOptionParseEnv

func RabOptionParseEnv(eo env.Options) (opts []RabOption, err error)

RabOptionParseEnv will parse environment variables into a slice of options. Any options for parsing the environment can be supplied, for example to parse under a prefix.

func WithHomeRabOption

func WithHomeRabOption(v string) RabOption

WithHomeRabOption configures: User's home directory

Jump to

Keyboard shortcuts

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