config

package
v0.0.0-...-a7d12b1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalDotEnv

func MarshalDotEnv(cfgs ...any) ([]byte, error)

func RegisterFlags

func RegisterFlags[T any](config *T, persistent bool, app *cobra.Command, options ...ParseOption) func() error

Parse takes every object and is able to fill and validate that object depending on config file, env file and flag values. https://github.com/knadh/koanf Your passed struct must define . delimited koanf struct tags in order to match env/.env and flag values to your struct. Additionally your struct may define a Validate() error method which is called at the end of parsing the config Registers flags and returns a parser function that can be used as PreRunE.

Types

type Config

type Config struct {
	Sorted bool `koanf:"sorted" short:"s" description:"sort the results"`
}

func (*Config) Validate

func (c *Config) Validate() error

type ParseOption

type ParseOption func(*parseOption)

func WithDelimiter

func WithDelimiter(delimiter string) ParseOption

func WithDescriptionStructTagName

func WithDescriptionStructTagName(tag string) ParseOption

func WithEnvPrefix

func WithEnvPrefix(prefix string) ParseOption

func WithStructTagName

func WithStructTagName(tag string) ParseOption

type Validatable

type Validatable interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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