null

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2016 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// NoType values are null.Type constants for convenience and readability
	NoBool    Bool    = Bool{Valid: false}
	NoString  String  = String{Valid: false}
	NoFloat   Float   = Float{Valid: false}
	NoInt     Int     = Int{Valid: false}
	NoTime    Time    = Time{Valid: false}
	NoDate    Date    = Date{Valid: false}
	NoUUID    UUID    = UUID{Valid: false}
	NoVersion Version = Version{Valid: false}
)
View Source
var JsonNull = []byte("null")

Functions

This section is empty.

Types

type Bool

type Bool sql.NullBool

Bool is a nullable boolean that doesn't require an extra allocation or dereference. The builting sql package has a NullBool, but it doesn't implement json.Marshaler.

func SomeBool

func SomeBool(value bool) Bool

func (Bool) MarshalJSON

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

Implement json.Marshaler interface

func (*Bool) Scan

func (n *Bool) Scan(src interface{}) error

Implement sql.Scanner interface

func (*Bool) Set

func (n *Bool) Set(value bool)

func (*Bool) UnmarshalJSON

func (n *Bool) UnmarshalJSON(bytes []byte) error

Implement json.Unmarshaler interface

func (*Bool) Unset

func (n *Bool) Unset()

func (Bool) Value

func (n Bool) Value() (driver.Value, error)

Implement driver.Valuer interface

type Date

type Date struct {
	Date  date.Date
	Valid bool
}

Date is a nullable date.Date that doesn't require an extra allocation or dereference. It supports encoding/decoding with database/sql, encoding/gob, and encoding/json.

func SomeDate

func SomeDate(value date.Date) Date

func (Date) MarshalJSON

func (n Date) MarshalJSON() ([]byte, error)

Implement json.Marshaler interface

func (*Date) Scan

func (n *Date) Scan(src interface{}) error

Implement sql.Scanner interface

func (*Date) Set

func (n *Date) Set(value date.Date)

func (*Date) UnmarshalJSON

func (n *Date) UnmarshalJSON(bytes []byte) error

Implement json.Unmarshaler interface

func (*Date) Unset

func (n *Date) Unset()

func (Date) Value

func (n Date) Value() (driver.Value, error)

Implement driver.Valuer interface

type Float

type Float struct {
	Float float64
	Valid bool
}

Float is a nullable float64 that doesn't require an extra allocation or dereference. The builting sql package has a NullFloat64, but it doesn't implement json.Marshaler.

func SomeFloat

func SomeFloat(value float64) Float

func (Float) MarshalJSON

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

Implement json.Marshaler interface

func (*Float) Scan

func (n *Float) Scan(src interface{}) error

Implement sql.Scanner interface

func (*Float) Set

func (n *Float) Set(value float64)

func (*Float) UnmarshalJSON

func (n *Float) UnmarshalJSON(bytes []byte) error

Implement json.Unmarshaler interface

func (*Float) Unset

func (n *Float) Unset()

func (Float) Value

func (n Float) Value() (driver.Value, error)

Implement driver.Valuer interface

type Int

type Int struct {
	Int   int
	Valid bool
}

Int is a nullable int that doesn't require an extra allocation or dereference. The builting sql package has a NullInt64, but it doesn't implement json.Marshaler and is an int64 instead of an int.

func SomeInt

func SomeInt(value int) Int

func (Int) MarshalJSON

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

Implement json.Marshaler interface

func (*Int) Scan

func (n *Int) Scan(src interface{}) error

Implement sql.Scanner interface

func (*Int) Set

func (n *Int) Set(value int)

func (*Int) UnmarshalJSON

func (n *Int) UnmarshalJSON(bytes []byte) error

Implement json.Unmarshaler interface

func (*Int) Unset

func (n *Int) Unset()

func (Int) Value

func (n Int) Value() (driver.Value, error)

Implement driver.Valuer interface

type String

type String sql.NullString

String is a nullable string that doesn't require an extra allocation or dereference. The builting sql package has a NullString, but it doesn't implement json.Marshaler.

func SomeString

func SomeString(value string) String

func (String) MarshalJSON

func (n String) MarshalJSON() ([]byte, error)

Implement json.Marshaler interface

func (*String) Scan

func (n *String) Scan(src interface{}) error

Implement sql.Scanner interface

func (*String) Set

func (n *String) Set(value string)

func (*String) UnmarshalJSON

func (n *String) UnmarshalJSON(bytes []byte) error

Implement json.Unmarshaler interface

func (*String) Unset

func (n *String) Unset()

func (String) Value

func (n String) Value() (driver.Value, error)

Implement driver.Valuer interface

type Time

type Time struct {
	Time  time.Time
	Valid bool
}

Time is a nullable time.Time that doesn't require an extra allocation or dereference. It supports encoding/decoding with database/sql, encoding/gob, and encoding/json.

func SomeTime

func SomeTime(value time.Time) Time

func (Time) MarshalJSON

func (n Time) MarshalJSON() ([]byte, error)

Implement json.Marshaler interface

func (*Time) Scan

func (n *Time) Scan(src interface{}) error

Implement sql.Scanner interface

func (*Time) Set

func (n *Time) Set(value time.Time)

func (*Time) UnmarshalJSON

func (n *Time) UnmarshalJSON(bytes []byte) error

Implement json.Unmarshaler interface

func (*Time) Unset

func (n *Time) Unset()

func (Time) Value

func (n Time) Value() (driver.Value, error)

Implement driver.Valuer interface

type UUID

type UUID struct {
	UUID  uuid.UUID
	Valid bool
}

UUID is a nullable uuid.UUID that doesn't require an extra allocation or dereference. It supports encoding/decoding with database/sql, encoding/gob, and encoding/json.

func SomeUUID

func SomeUUID(value uuid.UUID) UUID

func (UUID) MarshalJSON

func (n UUID) MarshalJSON() ([]byte, error)

Implement json.Marshaler interface

func (*UUID) Scan

func (n *UUID) Scan(src interface{}) error

Implement sql.Scanner interface.

func (*UUID) Set

func (n *UUID) Set(value uuid.UUID)

func (*UUID) UnmarshalJSON

func (n *UUID) UnmarshalJSON(bytes []byte) error

Implement json.Unmarshaler interface

func (*UUID) Unset

func (n *UUID) Unset()

func (UUID) Value

func (n UUID) Value() (driver.Value, error)

Implement driver.Valuer interface

type Version

type Version struct {
	Version semver.Version
	Valid   bool
}

Version is a nullable semver.Version that doesn't require an extra allocation or dereference. It supports encoding/decoding with database/sql, encoding/gob, and encoding/json.

func SomeVersion

func SomeVersion(value semver.Version) Version

func (Version) MarshalJSON

func (n Version) MarshalJSON() ([]byte, error)

Implement json.Marshaler interface

func (*Version) Scan

func (n *Version) Scan(src interface{}) error

Implement sql.Scanner interface.

func (*Version) Set

func (n *Version) Set(value semver.Version)

func (*Version) UnmarshalJSON

func (n *Version) UnmarshalJSON(bytes []byte) error

Implement json.Unmarshaler interface

func (*Version) Unset

func (n *Version) Unset()

func (Version) Value

func (n Version) Value() (driver.Value, error)

Implement driver.Valuer interface

Jump to

Keyboard shortcuts

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