envflag

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package envflag reads anfra's on/off environment variables. Each is 1 (on) or 0 (off); unset or empty means its default, and any other value is refused, at startup, so a typo surfaces at once rather than silently meaning the opposite.

Only anfra's own switches follow this rule. Standard variables keep their own conventions: CI (set by CI systems, to anything), OTEL_SDK_DISABLED (OpenTelemetry's, "true").

Index

Constants

View Source
const (
	LogStderr        = "ANFRA_LOG_STDERR"
	SidecarStdout    = "ANFRA_SIDECAR_STDOUT"
	NoUpdateNotifier = "ANFRA_NO_UPDATE_NOTIFIER"
	AutoUpdate       = "ANFRA_AUTO_UPDATE"
	HideErrorCauses  = "ANFRA_HIDE_ERROR_CAUSES"
)

The switches. Each is off by default, but LogStderr, which is on for `anfra serve` (OnOr).

Variables

This section is empty.

Functions

func On

func On(name string) bool

On reports whether the switch is on: 1. Unset, empty, 0, or (after Validate has refused it) any other value is off.

func OnOr added in v0.13.4

func OnOr(name string, def bool) bool

OnOr reports whether the switch is on: 1, or def when it is unset or empty. For a switch whose default depends on the command: 0 turns it off where it defaults to on.

func Validate

func Validate() error

Validate refuses a switch set to anything but 1 or 0, naming it and the value it has. Call it once, before anything reads a switch.

Types

type InvalidError added in v0.13.4

type InvalidError struct {
	Name  string // the variable, ANFRA_LOG_STDERR
	Value string // what it is set to
}

InvalidError is a switch set to something other than 1 or 0.

func (*InvalidError) Error added in v0.13.4

func (e *InvalidError) Error() string

Jump to

Keyboard shortcuts

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