optional

package
v0.0.0-...-27c7031 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type A

type A int

template type Optional(A)

type Optional

type Optional struct {
	V       A
	Defined bool
}

A 'gotemplate'-based type for providing optional semantics without using pointers.

func OOptional

func OOptional(v A) Optional

Creates an optional type with a given value.

func (Optional) Get

func (v Optional) Get(deflt A) A

Get returns the value or given default in the case the value is undefined.

func (Optional) IsDefined

func (v Optional) IsDefined() bool

IsDefined returns whether the value is defined, a function is required so that it can be used in an interface.

func (Optional) MarshalJSON

func (v Optional) MarshalJSON() ([]byte, error)

MarshalJSON implements a standard json marshaler interface.

func (Optional) MarshalPartialJSON

func (v Optional) MarshalPartialJSON(w *jwriter.Writer)

MarshalPartialJSON does JSON marshaling using partialencode interface.

func (Optional) String

func (v Optional) String() string

String implements a stringer interface using fmt.Sprint for the value.

func (*Optional) UnMarshalPartialJSON

func (v *Optional) UnMarshalPartialJSON(l *jlexer.Lexer)

UnMarshalPartialJSON does JSON unmarshaling using partialencode interface.

func (*Optional) UnmarshalJSON

func (v *Optional) UnmarshalJSON(data []byte) error

UnmarshalJSON implements a standard json unmarshaler interface.

Jump to

Keyboard shortcuts

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