flagutil

package
v0.0.0-...-8e06183 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: Apache-2.0 Imports: 16 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtrValue

func BoolPtrValue(val *bool, p **bool) pflag.Value

func BytesPtrValue

func BytesPtrValue(val []byte, p *[]byte) pflag.Value

func DurationpbSliceValue

func DurationpbSliceValue(val []time.Duration, p *[]*durationpb.Duration) pflag.Value

func DurationpbValue

func DurationpbValue(val *time.Duration, p **durationpb.Duration) pflag.Value

func EnumPtrValue

func EnumPtrValue[E protoenum[E]](val *E, p **E) pflag.Value

func EnumValue

func EnumValue[E protoenum[E]](val E, p *E) pflag.Value

func FloatPtrValue

func FloatPtrValue[T constraints.Float](val *T, p **T) pflag.Value

func IPNetSliceValue

func IPNetSliceValue(val []string, p *[]string) pflag.Value

func IPNetValue

func IPNetValue(val string, p *string) pflag.Value

func IntPtrValue

func IntPtrValue[T constraints.Signed](val *T, p **T) pflag.Value

func LoadDefaults

func LoadDefaults[T FlagSetter](obj T)

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h. Negative durations are not supported.

func Ptr

func Ptr[T any](t T) *T

func SetDefValue

func SetDefValue(fs *pflag.FlagSet, name, value string)

Sets DefValue and calls Value.Set for a flag. Must only be used after calling AddFlagSet and before calling Parse.

func StringPtrValue

func StringPtrValue(val *string, p **string) pflag.Value

func StringToFloat64Value

func StringToFloat64Value(val map[string]float64, p *map[string]float64) pflag.Value

func TimestamppbValue

func TimestamppbValue(val *string, p **timestamppb.Timestamp) pflag.Value

func UintPtrValue

func UintPtrValue[T constraints.Unsigned](val *T, p **T) pflag.Value

Types

type FlagSetter

type FlagSetter interface {
	FlagSet(...string) *pflag.FlagSet
}

Jump to

Keyboard shortcuts

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