Documentation
¶
Overview ¶
Package pointy is a set of simple helper functions to provide a shorthand to get a pointer to a variable holding a constant.
Index ¶
- func Bool(x bool) *bool
- func BoolValue(p *bool, fallback bool) bool
- func Byte(x byte) *byte
- func ByteValue(p *byte, fallback byte) byte
- func Complex128(x complex128) *complex128
- func Complex128Value(p *complex128, fallback complex128) complex128
- func Complex64(x complex64) *complex64
- func Complex64Value(p *complex64, fallback complex64) complex64
- func Float32(x float32) *float32
- func Float32Value(p *float32, fallback float32) float32
- func Float64(x float64) *float64
- func Float64Value(p *float64, fallback float64) float64
- func Int(x int) *int
- func Int16(x int16) *int16
- func Int16Value(p *int16, fallback int16) int16
- func Int32(x int32) *int32
- func Int32Value(p *int32, fallback int32) int32
- func Int64(x int64) *int64
- func Int64Value(p *int64, fallback int64) int64
- func Int8(x int8) *int8
- func Int8Value(p *int8, fallback int8) int8
- func IntValue(p *int, fallback int) int
- func Rune(x rune) *rune
- func RuneValue(p *rune, fallback rune) rune
- func String(x string) *string
- func StringValue(p *string, fallback string) string
- func Uint(x uint) *uint
- func Uint16(x uint16) *uint16
- func Uint16Value(p *uint16, fallback uint16) uint16
- func Uint32(x uint32) *uint32
- func Uint32Value(p *uint32, fallback uint32) uint32
- func Uint64(x uint64) *uint64
- func Uint64Value(p *uint64, fallback uint64) uint64
- func Uint8(x uint8) *uint8
- func Uint8Value(p *uint8, fallback uint8) uint8
- func UintValue(p *uint, fallback uint) uint
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolValue ¶ added in v1.1.0
BoolValue returns the bool value pointed to by p or fallback if p is nil
func ByteValue ¶ added in v1.1.0
ByteValue returns the byte value pointed to by p or fallback if p is nil
func Complex128 ¶
func Complex128(x complex128) *complex128
Complex128 returns a pointer to a variable holding the supplied complex128 constant
func Complex128Value ¶ added in v1.1.0
func Complex128Value(p *complex128, fallback complex128) complex128
Complex128Value returns the complex128 value pointed to by p or fallback if p is nil
func Complex64Value ¶ added in v1.1.0
Complex64Value returns the complex64 value pointed to by p or fallback if p is nil
func Float32Value ¶ added in v1.1.0
Float32Value returns the float32 value pointed to by p or fallback if p is nil
func Float64Value ¶ added in v1.1.0
Float64Value returns the float64 value pointed to by p or fallback if p is nil
func Int16Value ¶ added in v1.1.0
Int16Value returns the int16 value pointed to by p or fallback if p is nil
func Int32Value ¶ added in v1.1.0
Int32Value returns the int32 value pointed to by p or fallback if p is nil
func Int64 ¶
Int64 returns a pointer to a variable holding the supplied int64 constant
Example ¶
This example returns a pointer to a variable holding the `int64` constant `2018`.
package main import ( "fmt" "github.com/mwielbut/pointy" ) func main() { foo := pointy.Int64(2018) fmt.Println("foo contains value:", *foo) }
Output:
func Int64Value ¶ added in v1.1.0
Int64Value returns the int64 value pointed to by p or fallback if p is nil
func Int8Value ¶ added in v1.1.0
Int8Value returns the int8 value pointed to by p or fallback if p is nil
func IntValue ¶ added in v1.1.0
IntValue returns the int value pointed to by p or fallback if p is nil
func RuneValue ¶ added in v1.1.0
RuneValue returns the rune value pointed to by p or fallback if p is nil
func String ¶
String returns a pointer to a variable holding the supplied string constant
Example ¶
This example returns a pointer to a variable holding the `string` constant "point to me".
package main import ( "fmt" "github.com/mwielbut/pointy" ) func main() { bar := pointy.String("point to me") fmt.Println("bar contains value:", *bar) }
Output:
func StringValue ¶ added in v1.1.0
StringValue returns the string value pointed to by p or fallback if p is nil
func Uint16Value ¶ added in v1.1.0
Uint16Value returns the uint16 value pointed to by p or fallback if p is nil
func Uint32Value ¶ added in v1.1.0
Uint32Value returns the uint32 value pointed to by p or fallback if p is nil
func Uint64Value ¶ added in v1.1.0
Uint64Value returns the uint64 value pointed to by p or fallback if p is nil
func Uint8Value ¶ added in v1.1.0
Uint8Value returns the uint8 value pointed to by p or fallback if p is nil
Types ¶
This section is empty.