penv

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const NoDescription = "No description"

Variables

View Source
var Prefix = "ENV_"

Functions

func DumpConfig

func DumpConfig(config any) map[string]DumpVar

func ProcessConfig

func ProcessConfig(config any) error

ProcessConfig automaticaly read flags and ENVs to structure.

config - must be a pointer to structure

var Config struct {
  Deployment string `default:"development"`
  Host       string `default:"127.0.0.1"`
  Port       string `default:"8080"`
}

func init() {
  if err := penv.ProcessConfig(&Config); err != nil {
    panic(err)
  }
}

Types

type DumpVar

type DumpVar struct {
	Name     string
	NameEnv  string
	NameFlag string
	Default  string
	Desc     string
	Type     string
	Value    string
	Secret   bool
	Required bool
}

Jump to

Keyboard shortcuts

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