config

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config implements a minimal viable config library.

Only configuration through environment variables are supported.

Example (Basic)
os.Setenv("NUM", "69")

var n int
fmt.Printf("%d\n", n)

config.Int(&n, "num")
fmt.Printf("%d\n", n)
Output:
0
69

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enum

func Enum(value flag.Value, key string, values ...string) error

Enum sets a flag.Value from an environment variable, from a limited set of allowed values.

func Float64

func Float64(p *float64, key string) error

Float64 sets an float64 value from an environment variable.

func Int

func Int(p *int, key string) error

Int sets an int value from an environment variable.

func Int64

func Int64(p *int64, key string) error

Int64 sets an int64 value from an environment variable.

func SetPrefix

func SetPrefix(s string)

SetPrefix adds a prefix to all keys used to set values.

Example
os.Setenv("FOO_NUM", "69")

config.SetPrefix("foo_")

var n int
fmt.Printf("%d\n", n)

config.Int(&n, "num")
fmt.Printf("%d\n", n)
Output:
0
69

func String

func String(p *string, key string) error

String sets a string value from an environment variable.

func Text

func Text(p encoding.TextUnmarshaler, key string) error

Text sets an encoding.TextUnmarshaler value from an environment variable.

func Uint

func Uint(p *uint, key string) error

Uint sets an uint value from an environment variable.

func Uint64

func Uint64(p *uint64, key string) error

Uint64 sets an uint64 value from an environment variable.

func Value

func Value(value flag.Value, key string) error

Value sets a flag.Value from an environment variable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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