ptr

package
v0.0.0-...-c8a214a Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: Apache-2.0 Imports: 1 Imported by: 11

Documentation

Overview

Package ptr provides convenience and conversion methods for working with pointer types. This package was initially forked/lifted from https://github.com/aws/aws-sdk-go/blob/v1.1.35/aws/convert_types.go and has since drifted to include a few other conversions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a pointer to the bool value passed in.

func BoolEqual

func BoolEqual(a, b *bool) bool

BoolEqual compares two bool pointer values

func BoolMap

func BoolMap(src map[string]bool) map[string]*bool

BoolMap converts a string map of bool values into a string map of bool pointers

func BoolSlice

func BoolSlice(src []bool) []*bool

BoolSlice converts a slice of bool values into a slice of bool pointers

func BoolValue

func BoolValue(v *bool) bool

BoolValue returns the value of the bool pointer passed in or false if the pointer is nil.

func BoolValueMap

func BoolValueMap(src map[string]*bool) map[string]bool

BoolValueMap converts a string map of bool pointers into a string map of bool values

func BoolValueSlice

func BoolValueSlice(src []*bool) []bool

BoolValueSlice converts a slice of bool pointers into a slice of bool values

func CompareBools

func CompareBools(a, b *bool) int

CompareBools treats nil pointers as less than non-nil pointers. False is considered less than true.

func CompareInts

func CompareInts(a, b *int) int

CompareInts treats nil pointers as being less than non-nil pointers. It falls back on int comparison when both arguments are non-nil.

func Duration

func Duration(v time.Duration) *time.Duration

Duration returns a pointer to the time.Duration value passed in.

func DurationValue

func DurationValue(v *time.Duration) time.Duration

DurationValue returns the value of the time.Duration pointer passed in or 0 if the pointer is nil.

func Float64

func Float64(v float64) *float64

Float64 returns a pointer to the float64 value passed in.

func Float64Map

func Float64Map(src map[string]float64) map[string]*float64

Float64Map converts a string map of float64 values into a string map of float64 pointers

func Float64Slice

func Float64Slice(src []float64) []*float64

Float64Slice converts a slice of float64 values into a slice of float64 pointers

func Float64Value

func Float64Value(v *float64) float64

Float64Value returns the value of the float64 pointer passed in or 0 if the pointer is nil.

func Float64ValueMap

func Float64ValueMap(src map[string]*float64) map[string]float64

Float64ValueMap converts a string map of float64 pointers into a string map of float64 values

func Float64ValueSlice

func Float64ValueSlice(src []*float64) []float64

Float64ValueSlice converts a slice of float64 pointers into a slice of float64 values

func Int

func Int(v int) *int

Int returns a pointer to the int value passed in.

func Int32

func Int32(v int32) *int32

Int32 returns a pointer to the int32 value passed in.

func Int32Value

func Int32Value(v *int32) int32

Int32Value returns the value of the int32 pointer passed in or 0 if the pointer is nil.

func Int64

func Int64(v int64) *int64

Int64 returns a pointer to the int64 value passed in.

func Int64Map

func Int64Map(src map[string]int64) map[string]*int64

Int64Map converts a string map of int64 values into a string map of int64 pointers

func Int64Slice

func Int64Slice(src []int64) []*int64

Int64Slice converts a slice of int64 values into a slice of int64 pointers

func Int64Value

func Int64Value(v *int64) int64

Int64Value returns the value of the int64 pointer passed in or 0 if the pointer is nil.

func Int64ValueMap

func Int64ValueMap(src map[string]*int64) map[string]int64

Int64ValueMap converts a string map of int64 pointers into a string map of int64 values

func Int64ValueSlice

func Int64ValueSlice(src []*int64) []int64

Int64ValueSlice converts a slice of int64 pointers into a slice of int64 values

func IntEqual

func IntEqual(a, b *int) bool

IntEqual compares two int pointer values

func IntMap

func IntMap(src map[string]int) map[string]*int

IntMap converts a string map of int values into a string map of int pointers

func IntSlice

func IntSlice(src []int) []*int

IntSlice converts a slice of int values into a slice of int pointers

func IntValue

func IntValue(v *int) int

IntValue returns the value of the int pointer passed in or 0 if the pointer is nil.

func IntValueMap

func IntValueMap(src map[string]*int) map[string]int

IntValueMap converts a string map of int pointers into a string map of int values

func IntValueOk

func IntValueOk(i *int) (int, bool)

IntValueOk unpacks an int pointer and returns true if it's non-nil.

func IntValueSlice

func IntValueSlice(src []*int) []int

IntValueSlice converts a slice of int pointers into a slice of int values

func String

func String(v string) *string

String returns a pointer to the string value passed in.

func StringEqual

func StringEqual(a, b *string) bool

StringEqual compares two string pointer values

func StringMap

func StringMap(src map[string]string) map[string]*string

StringMap converts a string map of string values into a string map of string pointers

func StringSlice

func StringSlice(src []string) []*string

StringSlice converts a slice of string values into a slice of string pointers

func StringValue

func StringValue(v *string) string

StringValue returns the value of the string pointer passed in or "" if the pointer is nil.

func StringValueMap

func StringValueMap(src map[string]*string) map[string]string

StringValueMap converts a string map of string pointers into a string map of string values

func StringValueSlice

func StringValueSlice(src []*string) []string

StringValueSlice converts a slice of string pointers into a slice of string values

func Time

func Time(v time.Time) *time.Time

Time returns a pointer to the time.Time value passed in.

func TimeMap

func TimeMap(src map[string]time.Time) map[string]*time.Time

TimeMap converts a string map of time.Time values into a string map of time.Time pointers

func TimeSlice

func TimeSlice(src []time.Time) []*time.Time

TimeSlice converts a slice of time.Time values into a slice of time.Time pointers

func TimeValue

func TimeValue(v *time.Time) time.Time

TimeValue returns the value of the time.Time pointer passed in or time.Time{} if the pointer is nil.

func TimeValueMap

func TimeValueMap(src map[string]*time.Time) map[string]time.Time

TimeValueMap converts a string map of time.Time pointers into a string map of time.Time values

func TimeValueSlice

func TimeValueSlice(src []*time.Time) []time.Time

TimeValueSlice converts a slice of time.Time pointers into a slice of time.Time values

func Uint

func Uint(u uint) *uint

Uint returns a pointer to the uint value passed in.

func Uint64

func Uint64(v uint64) *uint64

Uint64 returns a pointer to the uint64 value passed in.

func Uint64Value

func Uint64Value(v *uint64) uint64

Uint64Value returns the value of the uint64 pointer passed in or 0 if the pointer is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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