pointer

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2018 License: BSD-1-Clause Imports: 0 Imported by: 0

README

package motivationalexample

import (
	"encoding/json"

	"github.com/tsavola/pointer"
)

const (
	defaultName = "some name"
)

// Stuff contains optional fields.
type Stuff struct {
	Name    *string
	Comment *string
	Value   *int64
}

// SomeStuff makes some JSON-encoded stuff.
func SomeStuff() (data []byte, err error) {
	return json.Marshal(&Stuff{
		Name:    pointer.String(defaultName), // can't say &defaultName
		Comment: pointer.String("not yet"),   // can't say &"not yet"
		Value:   pointer.Int64(42),           // can't say &42 or &int64(42)
	})
}

Documentation

Overview

Package pointer provides constructors for pointers of primitive types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(x bool) *bool

func Byte

func Byte(x byte) *byte

func Complex128

func Complex128(x complex128) *complex128

func Complex64

func Complex64(x complex64) *complex64

func Error

func Error(x error) *error

func Float32

func Float32(x float32) *float32

func Float64

func Float64(x float64) *float64

func Int

func Int(x int) *int

func Int16

func Int16(x int16) *int16

func Int32

func Int32(x int32) *int32

func Int64

func Int64(x int64) *int64

func Int8

func Int8(x int8) *int8

func Rune

func Rune(x rune) *rune

func String

func String(x string) *string

func Uint

func Uint(x uint) *uint

func Uint16

func Uint16(x uint16) *uint16

func Uint32

func Uint32(x uint32) *uint32

func Uint64

func Uint64(x uint64) *uint64

func Uint8

func Uint8(x uint8) *uint8

func Uintptr

func Uintptr(x uintptr) *uintptr

Types

This section is empty.

Jump to

Keyboard shortcuts

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