opt

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 1 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SumOptUint

func SumOptUint(opts ...Uint) uint64

SumOptUint sums a list of OptUint values

Types

type Bytes

type Bytes struct {
	Bytes uint64 `json:"bytes" struct:"bytes"`
}

Bytes wraps a uint64 byte value

type BytesOpt

type BytesOpt struct {
	Bytes Uint `json:"bytes" struct:"bytes"`
}

BytesOpt wraps a uint64 byte value in an option type

func (BytesOpt) IsZero

func (opt BytesOpt) IsZero() bool

IsZero returns true if the underlying value nil

type Float

type Float struct {
	// contains filtered or unexported fields
}

Float is a wrapper for "optional" types, with the bool value indicating if the stored int is a legitimate value.

func FloatWith

func FloatWith(f float64) Float

FloatWith returns a new uint wrapper for the specified value

func NewFloatNone

func NewFloatNone() Float

NewFloatNone returns a new uint wrapper

func (Float) Exists

func (opt Float) Exists() bool

Exists returns true if the underlying value exists

func (*Float) Fold

func (opt *Float) Fold(v structform.ExtVisitor) error

Fold implements the folder interface for OptUint

func (Float) IsZero

func (opt Float) IsZero() bool

IsZero returns true if the underlying value nil

func (Float) ValueOr

func (opt Float) ValueOr(f float64) float64

ValueOr returns the stored value, or zero Please do not use this for populating reported data, as we actually want to avoid sending zeros where values are functionally null

type Int

type Int struct {
	// contains filtered or unexported fields
}

Int is a wrapper for "optional" types, with the bool value indicating if the stored int is a legitimate value.

func IntWith

func IntWith(i int) Int

IntWith returns a new OptUint wrapper with a given int

func NewIntNone

func NewIntNone() Int

NewIntNone returns a new OptUint wrapper

func (Int) Exists

func (opt Int) Exists() bool

Exists returns true if the underlying value exists

func (*Int) Fold

func (opt *Int) Fold(v structform.ExtVisitor) error

Fold implements the folder interface for OptUint

func (Int) IsZero

func (opt Int) IsZero() bool

IsZero returns true if the underlying value nil

func (Int) ValueOr

func (opt Int) ValueOr(i int) int

ValueOr returns the stored value, or a given int Please do not use this for populating reported data, as we actually want to avoid sending zeros where values are functionally null

type Pct

type Pct struct {
	Pct float64 `json:"pct" struct:"pct"`
}

Pct wraps a float64 percent value

type PctOpt

type PctOpt struct {
	Pct Float `json:"pct" struct:"pct"`
}

PctOpt wraps a float64 percent value in an option type

func (PctOpt) IsZero

func (opt PctOpt) IsZero() bool

IsZero returns true if the underlying value nil

type Uint

type Uint struct {
	// contains filtered or unexported fields
}

Uint is a wrapper for "optional" types, with the bool value indicating if the stored int is a legitimate value.

func NewUintNone

func NewUintNone() Uint

NewUintNone returns a new OptUint wrapper

func UintWith

func UintWith(i uint64) Uint

UintWith returns a new OptUint wrapper with a given int

func (Uint) Exists

func (opt Uint) Exists() bool

Exists returns true if the underlying value exists

func (*Uint) Fold

func (opt *Uint) Fold(v structform.ExtVisitor) error

Fold implements the folder interface for OptUint

func (Uint) IsZero

func (opt Uint) IsZero() bool

IsZero returns true if the underlying value nil

func (Uint) MultUint64OrNone

func (opt Uint) MultUint64OrNone(i uint64) Uint

MultUint64OrNone or will multiply the existing Uint value by a supplied uint64, and return None if either the Uint is none, or the supplied uint64 is zero.

func (Uint) SubtractOrNone

func (opt Uint) SubtractOrNone(i Uint) Uint

SubtractOrNone will subtract the existing uint with the supplied uint64 value. If this would result in a value invalid for a uint (ie, a negative number), return None

func (Uint) ValueOr

func (opt Uint) ValueOr(i uint64) uint64

ValueOr returns the stored value, or a given int Please do not use this for populating reported data, as we actually want to avoid sending zeros where values are functionally null

type Us

type Us struct {
	Us uint64 `json:"us" struct:"us"`
}

Us wraps a uint64 microseconds value

type ZeroInterface

type ZeroInterface interface {
	IsZero() bool
}

ZeroInterface is a type interface for cases where we need to cast from a void pointer

Jump to

Keyboard shortcuts

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