confutil

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 5 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapContext

func WrapContext(ctx context.Context, c Config) context.Context

Types

type Config added in v0.6.14

type Config interface {
	Get(format string, args ...any) any
	GetBool(format string, args ...any) bool
	GetDuration(format string, args ...any) time.Duration
	GetFloat64(format string, args ...any) float64
	GetInt(format string, args ...any) int
	GetInt32(format string, args ...any) int32
	GetInt64(format string, args ...any) int64
	GetIntSlice(format string, args ...any) []int
	GetSizeInBytes(format string, args ...any) uint
	GetString(format string, args ...any) string
	GetStringMap(format string, args ...any) map[string]any
	GetStringMapString(format string, args ...any) map[string]string
	GetStringMapStringSlice(format string, args ...any) map[string][]string
	GetStringSlice(format string, args ...any) []string
	GetTime(format string, args ...any) time.Time
	GetUint(format string, args ...any) uint
	GetUint8(format string, args ...any) uint8
	GetUint16(format string, args ...any) uint16
	GetUint32(format string, args ...any) uint32
	GetUint64(format string, args ...any) uint64
	IsSet(format string, args ...any) bool
}

Config keys are Sprintf-ed only when args are given; an absent key reads zero, never an error.

func FromContext

func FromContext(ctx context.Context) Config

FromContext never returns nil: without a config every getter yields zero, so validate mandatory keys in Init.

func New added in v0.6.14

func New(v *viper.Viper) Config

New accepts a nil viper, yielding a Config whose getters all read zero.

Jump to

Keyboard shortcuts

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