config

package
v0.65.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config provides a global config store that other packages can utilise for fetching/storing configuration. The config store supports both file and environment configuration.

Index

Constants

View Source
const (
	// AppName is the application name.
	AppName = "Foragd"
	// AppID is the application name formatted for use as an ID.
	AppID = "app.foragd"
	// AppDescription is the catch-line of the application.
	AppDescription = "" /* 214-byte string literal not displayed */
	// ConfigEnvPrefix defines the environment variable prefix for reading
	// server configuration from the environment.
	ConfigEnvPrefix = "FORAGD_"
)

Variables

View Source
var (
	ErrLoadConfig    = errors.New("error loading config")
	ErrInvalidConfig = errors.New("invalid config")
)
View Source
var Init = sync.OnceValue(func() error {

	if Version == "_UNKNOWN_" {
		return fmt.Errorf("%w: version not set correctly", ErrLoadConfig)
	}

	CurrentEnvironment = Environment(os.Getenv("FORAGD_ENVIRONMENT"))

	return nil
})

Init ensures the application will have appropriate Version and Envrionment vars set.

View Source
var Version = "_UNKNOWN_"

Version is the application/stack version.

Functions

func Load

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

Load will load a config via environment variables with the given prefix into an object of the given type.

Types

type Environment

type Environment string
const (
	EnvDevelopment Environment = "development"
	EnvProduction  Environment = "production"
)
var CurrentEnvironment Environment

CurrentEnvironment is the environment in which the app is running (i.e., production, development).

type Timeout added in v0.56.0

type Timeout string

func (Timeout) Duration added in v0.56.0

func (t Timeout) Duration() time.Duration

func (Timeout) Validate added in v0.56.0

func (t Timeout) Validate() error

Jump to

Keyboard shortcuts

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