Documentation ¶
Overview ¶
Package pointer provides helpers to get pointers to values of build-in types.
Example ¶
const ( defaultName = "some name" ) // Stuff contains optional fields. type Stuff struct { Name *string Comment *string Value *int64 Time *time.Time } b, _ := json.Marshal(&Stuff{ Name: ToString(defaultName), // can't say &defaultName Comment: ToString("not yet"), // can't say &"not yet" Value: ToInt64(42), // can't say &42 or &int64(42) Time: ToTime(time.Date(2014, 6, 25, 12, 24, 40, 0, time.UTC)), // can't say &time.Date(…) }) fmt.Printf("%s", b)
Output: {"Name":"some name","Comment":"not yet","Value":42,"Time":"2014-06-25T12:24:40Z"}
Index ¶
- func ToBool(b bool) *bool
- func ToByte(b byte) *byte
- func ToComplex128(c complex128) *complex128
- func ToComplex64(c complex64) *complex64
- func ToError(e error) *error
- func ToFloat32(f float32) *float32
- func ToFloat64(f float64) *float64
- func ToInt(i int) *int
- func ToInt16(i int16) *int16
- func ToInt32(i int32) *int32
- func ToInt64(i int64) *int64
- func ToInt8(i int8) *int8
- func ToRune(r rune) *rune
- func ToString(s string) *string
- func ToTime(t time.Time) *time.Time
- func ToUint(u uint) *uint
- func ToUint16(u uint16) *uint16
- func ToUint32(u uint32) *uint32
- func ToUint64(u uint64) *uint64
- func ToUint8(u uint8) *uint8
- func ToUintptr(u uintptr) *uintptr
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToComplex128 ¶
func ToComplex128(c complex128) *complex128
func ToComplex64 ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.