Go package providing helper functions for working with settings
MIT License
validate
: linux only: handle permission denied on ip_unprivileged_port_start and return start port 1024 in that casePublished by qdm12 2 months ago
reader
: default force lowercase option to true to match documentationPublished by qdm12 7 months ago
Published by qdm12 7 months ago
reader
and internal/parse
packages which replace previous sources/env
and sources/merge
packages
internal/parse
contains only pure functions to make full use of Go 1.18+ genericsreader
package handling the merging)OverrideWithComparable
function, replacing OverrideWithNumber
, OverrideWithString
, OverrideWithPointerRaw
, OverrideWithInterface
and OverrideWithSliceRaw
DefaultComparable
function, replacing DefaultNumber
, DefaultString
, DefaultPointerRaw
, DefaultInterface
and DefaultSliceRaw
Number
constraint and constraints.go
file removed (no longer needed)reader/sources/env
environment variable reader-compatible sourcereader/sources/flags
CLI flags reader-compatible sourcereader
package (previously sources/env
):
DefaultOptions
setting to apply to each readFirstKeySet
methodCSVNetipAddresses
methodNetipPrefix
methodNetipAddrPort
methodCSVNetipAddrPorts
methodInt8
, Int16
, Int32
, Int64
, Int8Ptr
, Int16Ptr
, Int32Ptr
, Int64Ptr
, Float32
, Float32Ptr
and Float64Ptr
validate
: allow empty listening addressesvalidate
: listening port validation
internal/parse
(previously within sources/env/parse.go
):
AllowEmpty(true)
option is specifiedreader
and internal/parse
(previously sources/env
):
BoolPtr
returns nil
when the empty string is foundthe error context
to its message
CSVNetipPrefixes
method commentAcceptEmpty
option commentgolang.org/x/exp
Published by qdm12 9 months ago
validate
: unprivileged port start returned as default 1024 if kernel file not foundPublished by qdm12 9 months ago
validate
: listening port validation
Published by qdm12 10 months ago
Published by qdm12 11 months ago
reader
: Uint
returns a uint
not an int
reader
: add NetipPrefix
, NetipAddrPort
and CSVNetipAddrPorts
methodsPublished by qdm12 11 months ago
reader/parse
to internal/parse
golang.org/x/exp
reader
:
Int8
, Int16
, Int32
, Int64
, Int8Ptr
, Int16Ptr
, Int32Ptr
, Int64Ptr
, Float32
, Float32Ptr
and Float64Ptr
Published by qdm12 11 months ago
env.go
to its own reader/sources/env
packagereader/sources/flag
Published by qdm12 11 months ago
reader
package which replaces all sources
packages
sources/merger
removedsources/env
removed (replaced by reader
package)Env
reader-compatible Source
parse
package generic functions accept source interfaces instead of keyValues mapreader
package: New
takes a Settings struct as its unique argumentNumber
constraint and constraints.go
file removedOverrideWithComparable
function, replacing OverrideWithNumber
, OverrideWithString
, OverrideWithPointerRaw
, OverrideWithInterface
and OverrideWithSliceRaw
DefaultComparable
function, replacing DefaultNumber
, DefaultString
, DefaultPointerRaw
, DefaultInterface
and DefaultSliceRaw
parse
package: try parsing the empty string if AllowEmpty(true)
option is usedreader
package: add DefaultOptions
field to the Settings
structreader
package: add FirstKeySet
functionreader/parse
package:
handleDeprecatedKey
functionparseBool
returns a bool pointerthe error context
to its message
AcceptEmpty
option commentPublished by qdm12 over 1 year ago
sources/env
: add CSVNetipAddresses
methodvalidate
: ListeningAddress
accepts empty listening addressessources/env
: fix CSVNetipPrefixes
method commentPublished by qdm12 over 1 year ago
ObfuscateKey
functionBoolToYesNo
functionDefaultPointerRaw
functionsources/env
:
ForceLowercase
optionAcceptEmpty
optionString
function as a shorthand to return the empty string if the environment variable is not set or is the empty string.Uint32Ptr
methodDuration
methodBoolPtr
accepts true
and false
as string valuesRetroKeys
option
New
takes handleDeprecatedKey
functional argument, which can be left to nilsources/merger
package with sources merger generic codevalidate
:
AreAllOneOfCaseInsensitive
functionFileExists
functionDirectoryExists
functionListeningAddress
functionMergeWith
to be a value receiver and return a merged resultsources/env
:
Env
which is created with env.New(os.Environ())
Get
trims quotes by defaultGet
returns a string pointer, which is always nil
if the variable is not set, and can be nil
if empty values are not accepted (default). Most functions still return nil
if they get an empty string (i.e. Uint8Ptr
)sources/env
: trim both spaces and new lines if both are specifiedvalidate
: fix orStrings
functionMergeWithSlice
with nil argumentsexamples/merger/main.go
Names
string slice field to example settings in example/settings/settings.go
sources/env
:
Get
default behaviorTest_New
testgithub.com/qdm12/govalid
:
sources/env
: add unsigned and signed local parse functionssources/env
: package local parseBool
sources/env
:
Get
body into postProcessValue
functionGet
has a more flexible value trimming logicPublished by qdm12 over 1 year ago
sources/env
: comment on order of retro keyssources/env
: add Duration
methodPublished by qdm12 over 1 year ago
sources/env
: add Uint32Ptr
sources/env
: BoolPtr
accepts true and false as string valuessources/env
: add CSV functions for signed, unsigned and netip prefixessources/env
: add RetroKeys
option
New
takes handleDeprecatedKey
functional argument, which can be left to nilsources/env
: add unsigned and signed local parse functionssources/env
: package local parseBool
Published by qdm12 over 1 year ago
Test_New
testPublished by qdm12 over 1 year ago
Published by qdm12 over 1 year ago
Published by qdm12 over 1 year ago