envconf

package module
v1.10.14 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 18 Imported by: 11

README

EnvConf

GoDoc Widget codecov Go Report Card

Configuration generator and loader through environment variables

Rules

Documentation

Index

Constants

View Source
const (
	// DefaultListFormat constant to use to display usage in a list format
	DefaultListFormat = `` /* 316-byte string literal not displayed */

	// DefaultTableFormat constant to use to display usage in a tabular format
	DefaultTableFormat = `` /* 281-byte string literal not displayed */

)
View Source
const DefaultEndpointSeparator = "<|>"

Variables

View Source
var ErrInvalidSpecification = errors.New("specification must be a struct pointer")

ErrInvalidSpecification indicates that a specification is of the wrong type.

Functions

func CheckDisallowed added in v1.10.7

func CheckDisallowed(prefix string, spec interface{}) error

CheckDisallowed checks that no environment variables with the prefix are set that we don't know how or want to parse. This is likely only meaningful with a non-empty prefix.

func LoadDefaultFromYml added in v1.10.7

func LoadDefaultFromYml(filePath string) error

func MustProcess added in v1.10.7

func MustProcess(prefix string, spec interface{})

MustProcess is the same as Process but panics if an error occurs

func Process added in v1.10.7

func Process(prefix string, spec interface{}) error

Process populates the specified struct based on environment variables

func StringifyPath

func StringifyPath(paths ...interface{}) string

func UnmarshalExtra

func UnmarshalExtra(extra url.Values, v interface{}) error

func Usage added in v1.10.7

func Usage(prefix string, spec interface{}, security bool) error

Usage writes usage information to stdout using the default header and table format

func Usagef added in v1.10.7

func Usagef(prefix string, spec interface{}, out io.Writer, format string, security bool) error

Usagef writes usage information to the specified io.Writer using the specifed template specification

func Usaget added in v1.10.7

func Usaget(prefix string, spec interface{}, out io.Writer, tmpl *template.Template) error

Usaget writes usage information to the specified io.Writer using the specified template

Types

type Decoder added in v1.10.7

type Decoder interface {
	Decode(value string) error
}

Decoder has the same semantics as Setter, but takes higher precedence. It is provided for historical compatibility.

type Duration

type Duration time.Duration

func (Duration) MarshalText

func (d Duration) MarshalText() (text []byte, err error)

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

type Endpoint

type Endpoint struct {
	Scheme   string
	Hostname string
	Port     uint16
	Base     string
	Path     string
	Username string
	Password string
	Extra    url.Values
}

openapi:strfmt endpoint

func ParseEndpoint

func ParseEndpoint(text string) (*Endpoint, error)

func (Endpoint) Host

func (e Endpoint) Host() string

func (*Endpoint) IsTLS

func (e *Endpoint) IsTLS() bool

func (Endpoint) IsZero

func (e Endpoint) IsZero() bool

func (Endpoint) MarshalText

func (e Endpoint) MarshalText() (text []byte, err error)

func (Endpoint) SecurityString

func (e Endpoint) SecurityString() string

func (Endpoint) String

func (e Endpoint) String() string

func (*Endpoint) UnmarshalText

func (e *Endpoint) UnmarshalText(text []byte) error

type Endpoints added in v1.10.7

type Endpoints []Endpoint

openapi:strfmt endpoint

func (Endpoints) IsZero added in v1.10.7

func (e Endpoints) IsZero() bool

func (Endpoints) MarshalText added in v1.10.7

func (e Endpoints) MarshalText() (text []byte, err error)

func (Endpoints) SecurityString added in v1.10.7

func (e Endpoints) SecurityString() string

func (Endpoints) String added in v1.10.7

func (e Endpoints) String() string

func (*Endpoints) UnmarshalText added in v1.10.7

func (e *Endpoints) UnmarshalText(text []byte) error

type EnvVar

type EnvVar struct {
	Name