null

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: Apache-2.0 Imports: 2 Imported by: 2

README

null 🚫

GoDoc Go Report Card Build Status Codecov Version

Simple library for null values in Go

This library provides simple, idiomatic primitives for nullable values in Go. It supports Int, Bool, and Float types.

	// "b" is null, and ready to use
	var b null.Bool

	// Set value to false
	b.Set(false)

	// Set value to true
	b.Set(true)

	// Get the value
	b.Bool()

	// Make the value null again
	b.Unset()

Pull Requests Welcome

Please use GitHub to make suggestions, pull requests, and enhancements. We're all in this together! 🚫

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

Bool provides a nullable bool

func NewBool

func NewBool(value bool) Bool

NewBool returns a fully populated, nullable bool

func (Bool) Bool added in v0.2.0

func (b Bool) Bool() bool

Bool returns the actual value of this object

func (Bool) Interface added in v0.4.1

func (b Bool) Interface() interface{}

Interface returns the boolean value (if present) or NIL

func (Bool) IsNull

func (b Bool) IsNull() bool

IsNull returns TRUE if this value is null

func (Bool) IsPresent

func (b Bool) IsPresent() bool

IsPresent returns TRUE if this value is present

func (Bool) MarshalJSON added in v0.4.0

func (b Bool) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface

func (*Bool) Set

func (b *Bool) Set(value bool)

Set applies a new value to the nullable item

func (Bool) String added in v0.4.0

func (b Bool) String() string

func (*Bool) UnmarshalJSON added in v0.4.0

func (b *Bool) UnmarshalJSON(value []byte) error

UnmarshalJSON implements the json.Unmarshaller interface

func (*Bool) Unset

func (b *Bool) Unset()

Unset removes the value from this item, and sets it to null

type Float

type Float struct {
	// contains filtered or unexported fields
}

Float provides a nullable float64

func NewFloat

func NewFloat(value float64) Float

NewFloat returns a fully populated, nullable float64

func (Float) Float added in v0.2.0

func (f Float) Float() float64

Float returns the actual value of this object

func (Float) Interface added in v0.4.1

func (f Float) Interface() interface{}

Interface returns the float64 value (if present) or NIL

func (Float) IsNull

func (f Float) IsNull() bool

IsNull returns TRUE if this value is null

func (Float) IsPresent

func (f Float) IsPresent() bool

IsPresent returns TRUE if this value is present

func (Float) MarshalJSON added in v0.4.0

func (f Float) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface

func (*Float) Set

func (f *Float) Set(value float64)

Set applies a new value to the nullable item

func (Float) String added in v0.3.0

func (f Float) String() string

String returns a string representation of this value

func (*Float) UnmarshalJSON added in v0.4.0

func (f *Float) UnmarshalJSON(value []byte) error

UnmarshalJSON implements the json.Unmarshaller interface

func (*Float) Unset

func (f *Float) Unset()

Unset removes the value from this item, and sets it to null

type Int

type Int struct {
	// contains filtered or unexported fields
}

Int provides a nullable bool

func NewInt

func NewInt(value int) Int

NewInt returns a fully populated, nullable bool

func (Int) Int added in v0.2.0

func (i Int) Int() int

Int returns the actual value of this object

func (Int) Interface added in v0.4.1

func (i Int) Interface() interface{}

Interface returns the int value (if present) or NIL

func (Int) IsNull

func (i Int) IsNull() bool

IsNull returns TRUE if this value is null

func (Int) IsPresent

func (i Int) IsPresent() bool

IsPresent returns TRUE if this value is present

func (Int) MarshalJSON added in v0.4.0

func (i Int) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface

func (*Int) Set

func (i *Int) Set(value int)

Set applies a new value to the nullable item

func (Int) String added in v0.3.0

func (i Int) String() string

String returns a string representation of this value

func (*Int) UnmarshalJSON added in v0.4.0

func (i *Int) UnmarshalJSON(value []byte) error

UnmarshalJSON implements the json.Unmarshaller interface

func (*Int) Unset

func (i *Int) Unset()

Unset removes the value from this item, and sets it to null

Jump to

Keyboard shortcuts

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