envflag

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package envflag is a wrapper for stdlib's flag that adds the environment variables as additional source of the values for flags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(name string, defaultValue bool, usage string) (*bool, error)

Bool is a convenience wrapper for boolean flag that picks its default value from the environment variable. It returns error if the environment variable's value can not be resolved into definitive `true` or `false`.

func Int

func Int(name string, defaultValue int, usage string) (*int, error)

Int is a convenience wrapper for integer flag that picks its default value from the environment variable. It returns error if the environment variable's value can not be parsed into integer.

func MustBool

func MustBool(name string, defaultValue bool, usage string) *bool

MustBool handles error (if any) returned by Bool according to the behaviour configured by `flag.CommandLine.ErrorHandling()` by either ignoring it, exiting the process with status code 2, or panicking.

func MustInt

func MustInt(name string, defaultValue int, usage string) *int

MustInt handles error (if any) returned by Int according to the behaviour configured by `flag.CommandLine.ErrorHandling()` by either ignoring it, exiting the process with status code 2, or panicking.

func String

func String(name, defaultValue, usage string) *string

String is a convenience wrapper for string flag that picks its default value from the environment variable.

Types

This section is empty.

Jump to

Keyboard shortcuts

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