envflag

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: BSD-3-Clause Imports: 3 Imported by: 2 modules, 2 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

Overview

Package envflag sets command-line flags from environment variables, so a service can be configured either way: flags for development, and the environment in a container.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Name

func Name(prefix, flagName string) string

Name returns the environment variable for a flag: the prefix, then the flag's name in capitals with "-" as "_". The flag "dns-timeout" with the prefix "WHATSMYIP_" is WHATSMYIP_DNS_TIMEOUT.

func Set

func Set(fs *flag.FlagSet, prefix string, getenv func(string) string) error

Set sets each of fs's flags whose environment variable is set and not empty, using getenv (usually os.Getenv). Call it before fs.Parse, so a flag on the command line overrides its variable. It returns an error naming the variable if a value is invalid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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