null

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 6 Imported by: 0

README

Build Status Coverage Status Go Report Card

null

Types

Nullable types for Go. All types implement:

  • sql.Scanner
  • driver.Valuer
  • json.Marshaler
  • json.Unmarshaler
  • encoding.TextMarshaler
  • encoding.TextUnmarshaler
  • xml.Marshaler
  • xml.Unmarshaler

When marshaling xml, the attribute xsi:nil="true" will be added for null values. When unmarshaling xml, the value will be null if xsi:nil="true" is set.

Float64

null.Float64 is based on sql.NullFloat64 and exports the fields Float64 and Valid. Valid is true if Float64 is not null.

Int64

null.Int64 is based on sql.NullInt64 and exports the fields Int64 and Valid. Valid is true if Int64 is not null.

String

null.String is based on sql.NullString and exports the fields String and Valid. Valid is true if String is not null.

When using encoding.TextUnmarshaler, an empty text will be valid.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Float64

type Float64 struct {
	sql.NullFloat64
}

Float64 represents a float64 that may be null.

func NewFloat64

func NewFloat64(f float64) Float64

NewFloat64 creates a new Float64.

func NewFloat64Ptr

func NewFloat64Ptr(f float64) *Float64

NewFloat64Ptr creates a new Float64 pointer.

func (Float64) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

func (Float64) MarshalText

func (f Float64) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (Float64) MarshalXML

func (f Float64) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements the xml.Marshaler interface.

func (*Float64) UnmarshalJSON

func (f *Float64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Float64) UnmarshalText

func (f *Float64) UnmarshalText(data []byte) (err error)

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (*Float64) UnmarshalXML

func (f *Float64) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml.Unmarshaler interface.

type Int64

type Int64 struct {
	sql.NullInt64
}

Int64 represents a int64 that may be null.

func NewInt64

func NewInt64(i int64) Int64

NewInt64 creates a new Int64.

func NewInt64Ptr

func NewInt64Ptr(i int64) *Int64

NewInt64Ptr creates a new Int64 pointer.

func (Int64) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

func (Int64) MarshalText

func (i Int64) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (Int64) MarshalXML

func (i Int64) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements the xml.Marshaler interface.

func (*Int64) UnmarshalJSON

func (i *Int64) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Int64) UnmarshalText

func (i *Int64) UnmarshalText(data []byte) (err error)

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (*Int64) UnmarshalXML

func (i *Int64) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml.Unmarshaler interface.

type String

type String struct {
	sql.NullString
}

String represents a string that may be null.

func NewString

func NewString(s string) String

NewString creates a new String.

func NewStringPtr

func NewStringPtr(s string) *String

NewStringPtr creates a new String pointer.

func (String) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

func (String) MarshalText

func (s String) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (String) MarshalXML

func (s String) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements the xml.Marshaler interface.

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*String) UnmarshalText

func (s *String) UnmarshalText(data []byte) (err error)

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (*String) UnmarshalXML

func (s *String) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements the xml.Unmarshaler interface.

Jump to

Keyboard shortcuts

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