settings

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package settings holds the helpers an application needs on top of github.com/jessevdk/go-flags: every setting is an option with paired `long:` and `env:` tags, required settings fail at startup and name their environment variable, and credentials are Secrets that don't print.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(p *flags.Parser, args []string) ([]string, error)

Parse parses args with p and runs the active command, like p.ParseArgs, with one difference: a required option whose value is empty counts as missing. go-flags alone accepts an environment variable that exists but is empty, so a required DATABASE_URL= passes it.

A missing option fails before any command runs, with a *flags.Error of type flags.ErrRequired that names every missing option by both its flag and its environment variable. Create p without flags.PrintErrors, or go-flags prints its own message first.

Types

type Secret

type Secret string

Secret is a string setting that doesn't print: fmt, slog and JSON show it redacted. Reveal returns the value.

func (Secret) GoString

func (s Secret) GoString() string

GoString redacts the secret for %#v.

func (Secret) LogValue

func (s Secret) LogValue() slog.Value

LogValue redacts the secret for slog.

func (Secret) MarshalText

func (s Secret) MarshalText() ([]byte, error)

MarshalText redacts the secret for encoding/json and other text encoders.

func (Secret) Reveal

func (s Secret) Reveal() string

Reveal returns the secret's value, for the one place that needs it.

func (Secret) String

func (s Secret) String() string

String redacts a set secret. An empty one prints as empty, so a dump of the settings still shows which secrets are missing.

Jump to

Keyboard shortcuts

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