Documentation ¶
Overview ¶
package field provides utilities to set structure fields. It was inspired by the kubernetes package https://pkg.go.dev/k8s.io/utils/pointer.
Index ¶
- func OptionalAny(ptr *any, defaultValue any) any
- func OptionalBool(ptr *bool, defaultValue bool) bool
- func OptionalDuration(ptr *time.Duration, defaultValue time.Duration) time.Duration
- func OptionalFloat32(ptr *float32, defaultValue float32) float32
- func OptionalFloat64(ptr *float64, defaultValue float64) float64
- func OptionalInt(ptr *int, defaultValue int) int
- func OptionalInt32(ptr *int32, defaultValue int32) int32
- func OptionalInt64(ptr *int64, defaultValue int64) int64
- func OptionalString(ptr *string, defaultValue string) string
- func OptionalTime(ptr *time.Time, defaultValue time.Time) time.Time
- func OptionalUint(ptr *uint, defaultValue uint) uint
- func OptionalUint32(ptr *uint32, defaultValue uint32) uint32
- func OptionalUint64(ptr *uint64, defaultValue uint64) uint64
- func ToOptionalAny(a any) *any
- func ToOptionalBool(b bool) *bool
- func ToOptionalDuration(i time.Duration) *time.Duration
- func ToOptionalFloat32(i float32) *float32
- func ToOptionalFloat64(i float64) *float64
- func ToOptionalInt(i int) *int
- func ToOptionalInt32(i int32) *int32
- func ToOptionalInt64(i int64) *int64
- func ToOptionalString(s string) *string
- func ToOptionalTime(i time.Time) *time.Time
- func ToOptionalUint(i uint) *uint
- func ToOptionalUint32(i uint32) *uint32
- func ToOptionalUint64(i uint64) *uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OptionalAny ¶
OptionalAny returns the value of an optional field or else returns defaultValue.
func OptionalBool ¶
OptionalBool returns the value of an optional field or else returns defaultValue.
func OptionalDuration ¶
OptionalDuration returns the value of an optional field or else returns defaultValue.
func OptionalFloat32 ¶
OptionalFloat32 returns the value of an optional field or else returns defaultValue.
func OptionalFloat64 ¶
OptionalFloat64 returns the value of an optional field or else returns defaultValue.
func OptionalInt ¶
OptionalInt returns the value of an optional field or else returns defaultValue.
func OptionalInt32 ¶
OptionalInt32 returns the value of an optional field or else returns defaultValue.
func OptionalInt64 ¶
OptionalInt64 returns the value of an optional field or else returns defaultValue.
func OptionalString ¶
OptionalString returns the value of an optional field or else returns defaultValue.
func OptionalTime ¶ added in v1.30.0
OptionalTime returns the value of an optional field or else returns defaultValue.
func OptionalUint ¶
OptionalUint returns the value of an optional field or else returns defaultValue.
func OptionalUint32 ¶
OptionalUint32 returns the value of an optional field or else returns defaultValue.
func OptionalUint64 ¶
OptionalUint64 returns the value of an optional field or else returns defaultValue.
func ToOptionalDuration ¶
ToOptionalDuration returns a pointer to a Duration.
func ToOptionalFloat32 ¶
ToOptionalFloat32 returns a pointer to a float32.
func ToOptionalFloat64 ¶
ToOptionalFloat64 returns a pointer to a float64.
func ToOptionalInt32 ¶
ToOptionalInt32 returns a pointer to an int32.
func ToOptionalInt64 ¶
ToOptionalInt64 returns a pointer to an int64.
func ToOptionalString ¶
ToOptionalString returns a pointer to a string.
func ToOptionalTime ¶ added in v1.30.0
ToOptionalTime returns a pointer to a Time.
func ToOptionalUint32 ¶
ToOptionalUint32 returns a pointer to an uint32.
func ToOptionalUint64 ¶
ToOptionalUint64 returns a pointer to an uint64.
Types ¶
This section is empty.