pointer

package
Version: v0.0.0-...-6203023 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: Apache-2.0 Imports: 2 Imported by: 1,128

README

Pointer

This package provides some functions for pointer-based operations.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoolPtr = Bool // for back-compat
View Source
var BoolPtrDerefOr = BoolDeref // for back-compat
View Source
var Float32Ptr = Float32
View Source
var Float32PtrDerefOr = Float32Deref // for back-compat
View Source
var Float64Ptr = Float64
View Source
var Float64PtrDerefOr = Float64Deref // for back-compat
View Source
var Int32Ptr = Int32 // for back-compat
View Source
var Int32PtrDerefOr = Int32Deref // for back-compat
View Source
var Int64Ptr = Int64 // for back-compat
View Source
var Int64PtrDerefOr = Int64Deref // for back-compat
View Source
var IntPtr = Int // for back-compat
View Source
var IntPtrDerefOr = IntDeref // for back-compat
View Source
var StringPtr = String // for back-compat
View Source
var StringPtrDerefOr = StringDeref // for back-compat

Functions

func AllPtrFieldsNil

func AllPtrFieldsNil(obj interface{}) bool

AllPtrFieldsNil tests whether all pointer fields in a struct are nil. This is useful when, for example, an API struct is handled by plugins which need to distinguish "no plugin accepted this spec" from "this spec is empty".

This function is only valid for structs and pointers to structs. Any other type will cause a panic. Passing a typed nil pointer will return true.

func Bool

func Bool(b bool) *bool

Bool returns a pointer to a bool.

func BoolDeref

func BoolDeref(ptr *bool, def bool) bool

BoolDeref dereferences the bool ptr and returns it if not nil, or else returns def.

func BoolEqual

func BoolEqual(a, b *bool) bool

BoolEqual returns true if both arguments are nil or both arguments dereference to the same value.

func Float32

func Float32(i float32) *float32

Float32 returns a pointer to the a float32.

func Float32Deref

func Float32Deref(ptr *float32, def float32) float32

Float32Deref dereferences the float32 ptr and returns it if not nil, or else returns def.

func Float32Equal

func Float32Equal(a, b *float32) bool

Float32Equal returns true if both arguments are nil or both arguments dereference to the same value.

func Float64

func Float64(i float64) *float64

Float64 returns a pointer to the a float64.

func Float64Deref

func Float64Deref(ptr *float64, def float64) float64

Float64Deref dereferences the float64 ptr and returns it if not nil, or else returns def.

func Float64Equal

func Float64Equal(a, b *float64) bool

Float64Equal returns true if both arguments are nil or both arguments dereference to the same value.

func Int

func Int(i int) *int

Int returns a pointer to an int

func Int32

func Int32(i int32) *int32

Int32 returns a pointer to an int32.

func Int32Deref

func Int32Deref(ptr *int32, def int32) int32

Int32Deref dereferences the int32 ptr and returns it if not nil, or else returns def.

func Int32Equal

func Int32Equal(a, b *int32) bool

Int32Equal returns true if both arguments are nil or both arguments dereference to the same value.

func Int64

func Int64(i int64) *int64

Int64 returns a pointer to an int64.

func Int64Deref

func Int64Deref(ptr *int64, def int64) int64

Int64Deref dereferences the int64 ptr and returns it if not nil, or else returns def.

func Int64Equal

func Int64Equal(a, b *int64) bool

Int64Equal returns true if both arguments are nil or both arguments dereference to the same value.

func IntDeref

func IntDeref(ptr *int, def int) int

IntDeref dereferences the int ptr and returns it if not nil, or else returns def.

func String

func String(s string) *string

String returns a pointer to a string.

func StringDeref

func StringDeref(ptr *string, def string) string

StringDeref dereferences the string ptr and returns it if not nil, or else returns def.

func StringEqual

func StringEqual(a, b *string) bool

StringEqual returns true if both arguments are nil or both arguments dereference to the same value.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

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