settingsutils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 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

View Source
var ServiceSettings serviceSettings

ServiceSettings holds the process-wide service configuration, populated from SERVICE_-prefixed environment variables during package init.

Functions

func GetSettings

func GetSettings[T any](envPrefix string) (T, error)

GetSettings Initialize settings, example:

 type tg struct {
   Token string `env:"TOKEN,required"`
 }

 type serviceSettings struct {
	TG  tg  `env:"TG" envPrefix:"TG__"`
 }

 func init() {
	  Settings = settingsutils.MustGetSetting[serviceSettings]("TEAS_")
 }

 var Settings serviceSettings

Returns error if dotEnv file found, but corrupted.

func MustGetSetting

func MustGetSetting[T any](envPrefix string) T

MustGetSetting is like GetSettings but panics on error; use it at startup (e.g. in package init) where invalid configuration should abort the process.

Types

This section is empty.

Jump to

Keyboard shortcuts

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