config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config declares the environment variables an application reads and checks them all at once before it starts. Environment variables hold deployment values and secrets only; everything else belongs in code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppKit

type AppKit struct {
	App       AppSettings
	Sessions  identity.SessionConfig // the application still sets Policy
	MasterKey *encryption.Key        // nil when APP_MASTER_KEY is missing or invalid; Check reports why
}

AppKit holds every value AppKit reads from the environment.

type AppSettings

type AppSettings struct {
	DatabasePath  string
	ListenAddress string
	Environment   string
}

AppSettings are the application-wide values the application runs with.

func (AppSettings) Development

func (settings AppSettings) Development() bool

Development reports whether APP_ENV is development.

type Defaults

type Defaults struct {
	DatabasePath  string // DATABASE_PATH
	ListenAddress string // LISTEN_ADDRESS
	Environment   string // APP_ENV
}

Defaults replaces AppKit's defaults for the application-wide variables. Empty fields keep AppKit's: app.sqlite, 127.0.0.1:8080, and production.

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

Environment collects declarations. AppKit packages declare their own variables through it, and the application adds its own.

func New

func New() *Environment

New starts an empty set of declarations read from the process environment.

func (*Environment) AppKit

func (environment *Environment) AppKit(defaults Defaults) AppKit

AppKit declares and reads every AppKit variable. An application usually passes config.Defaults{}.

func (*Environment) Check

func (environment *Environment) Check() error

Check returns every missing or invalid variable in one error. When there are none and APP_ENV is development, it logs each optional variable that uses its default.

func (*Environment) Invalid

func (environment *Environment) Invalid(name, reason string)

Invalid records a declared variable whose value cannot be used.

func (*Environment) Optional

func (environment *Environment) Optional(name, fallback, description string) string

Optional declares a variable with a default and returns its value.

func (*Environment) Required

func (environment *Environment) Required(name, description string) string

Required declares a variable that must be set and returns its value.

Jump to

Keyboard shortcuts

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