nulltype

package module
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

README

NullType

Description

This package provides some types representing a type that may be null. NullType implements the sql.Scanner, json.Unmarshaler and json.Marshaler interface for :

  • time.Time
  • string
  • int64
  • int32
  • int16
  • int8
  • uint64
  • uint32
  • uint16
  • uint8
  • bool
  • float64
  • uuid.UUID

NullType and omitempty

By default NullType struct are not empty. To make omitempty tag functional on not valid NullType you have to call EncoderRegister() at the beginning of your program.

Authors

  • Mickael ROUSSE
  • Vincent PEREZ
  • Corentin Gaspart

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool sql.NullBool

func NewBool

func NewBool(b bool) Bool

func (*Bool) Encode

func (nb *Bool) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Bool) IsEmpty

func (nb *Bool) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Bool) MarshalCSV

func (nb Bool) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Bool) MarshalJSON

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

func (*Bool) Scan

func (nb *Bool) Scan(value interface{}) error

func (*Bool) UnmarshalCSV

func (nb *Bool) UnmarshalCSV(b string) error

func (*Bool) UnmarshalJSON

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

func (Bool) Value

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

type Float64

type Float64 sql.NullFloat64

func NewFloat64

func NewFloat64(f float64) Float64

func (*Float64) Encode

func (nf *Float64) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Float64) IsEmpty

func (nf *Float64) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Float64) MarshalCSV

func (nf Float64) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Float64) MarshalJSON

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

func (*Float64) Scan

func (nf *Float64) Scan(value interface{}) error

func (*Float64) UnmarshalCSV

func (nf *Float64) UnmarshalCSV(b string) error

func (*Float64) UnmarshalJSON

func (nf *Float64) UnmarshalJSON(b []byte) error

func (Float64) Value

func (nf Float64) Value() (driver.Value, error)

type Int16

type Int16 sql.NullInt16

func NewInt16

func NewInt16(i int16) Int16

func (*Int16) Encode

func (ni *Int16) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Int16) IsEmpty

func (ni *Int16) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Int16) MarshalCSV

func (ni Int16) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Int16) MarshalJSON

func (ni Int16) MarshalJSON() ([]byte, error)

func (*Int16) Scan

func (ni *Int16) Scan(value any) error

func (*Int16) UnmarshalCSV

func (ni *Int16) UnmarshalCSV(b string) error

func (*Int16) UnmarshalJSON

func (ni *Int16) UnmarshalJSON(b []byte) error

func (Int16) Value

func (ni Int16) Value() (driver.Value, error)

type Int32

type Int32 sql.NullInt32

func NewInt32

func NewInt32(i int32) Int32

func (*Int32) Encode

func (ni *Int32) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Int32) IsEmpty

func (ni *Int32) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Int32) MarshalCSV

func (ni Int32) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Int32) MarshalJSON

func (ni Int32) MarshalJSON() ([]byte, error)

func (*Int32) Scan

func (ni *Int32) Scan(value any) error

func (*Int32) UnmarshalCSV

func (ni *Int32) UnmarshalCSV(b string) error

func (*Int32) UnmarshalJSON

func (ni *Int32) UnmarshalJSON(b []byte) error

func (Int32) Value

func (ni Int32) Value() (driver.Value, error)

type Int64

type Int64 sql.NullInt64

func NewInt64

func NewInt64(i int64) Int64

func (*Int64) Encode

func (ni *Int64) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Int64) IsEmpty

func (ni *Int64) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Int64) MarshalCSV

func (ni Int64) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Int64) MarshalJSON

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

func (*Int64) Scan

func (ni *Int64) Scan(value any) error

func (*Int64) UnmarshalCSV

func (ni *Int64) UnmarshalCSV(b string) error

func (*Int64) UnmarshalJSON

func (ni *Int64) UnmarshalJSON(b []byte) error

func (Int64) Value

func (ni Int64) Value() (driver.Value, error)

type Int8

type Int8 struct {
	Int8  int8
	Valid bool // Valid is true if Uint8 is not NULL
}

func NewInt8

func NewInt8(i int8) Int8

func (*Int8) Encode

func (ni *Int8) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Int8) IsEmpty

func (ni *Int8) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Int8) MarshalCSV

func (ni Int8) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Int8) MarshalJSON

func (ni Int8) MarshalJSON() ([]byte, error)

func (*Int8) Scan

func (ni *Int8) Scan(value any) error

func (*Int8) UnmarshalCSV

func (ni *Int8) UnmarshalCSV(b string) error

func (*Int8) UnmarshalJSON

func (ni *Int8) UnmarshalJSON(b []byte) error

func (Int8) Value

func (ni Int8) Value() (driver.Value, error)

type RawBytes

type RawBytes []byte

RawBytes is a byte slice that holds a reference to memory owned by the database itself. After a Scan into a RawBytes, the slice is only valid until the next call to Next, Scan, or Close.

type String

type String sql.NullString

func NewString

func NewString(str string) String

func (*String) Encode

func (ns *String) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*String) IsEmpty

func (ns *String) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (String) MarshalCSV

func (ns String) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (String) MarshalJSON

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

func (*String) Scan

func (ns *String) Scan(value interface{}) error

func (*String) UnmarshalCSV

func (ns *String) UnmarshalCSV(b string) error

func (*String) UnmarshalJSON

func (ns *String) UnmarshalJSON(b []byte) error

func (String) Value

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

type Time

type Time struct {
	Time     time.Time
	Timezone string
	Valid    bool
}

func NewTime

func NewTime(t time.Time) Time

func (*Time) Encode

func (n *Time) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Time) IsEmpty

func (n *Time) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Time) MarshalCSV

func (n Time) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Time) MarshalJSON

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

func (Time) MarshalText

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

func (*Time) Scan

func (nt *Time) Scan(value interface{}) (err error)

func (Time) String

func (n Time) String() string

func (*Time) UnmarshalCSV

func (n *Time) UnmarshalCSV(b string) error

func (*Time) UnmarshalJSON

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

func (Time) Value

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

type UUID

type UUID struct {
	UUID uuid.UUID
	/* Valid is true if UUID is not NULL*/
	Valid bool
}

func NewUUID

func NewUUID(u uuid.UUID) UUID

NewUUID creates a valid null.UUID using a uuid.UUID

func (*UUID) Encode

func (n *UUID) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*UUID) IsEmpty

func (n *UUID) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (*UUID) MarshalCSV

func (n *UUID) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (UUID) MarshalJSON

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

func (*UUID) Scan

func (n *UUID) Scan(value interface{}) (err error)

func (*UUID) UnmarshalCSV

func (n *UUID) UnmarshalCSV(b string) error

func (*UUID) UnmarshalJSON

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

func (UUID) Value

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

type Uint16

type Uint16 struct {
	Uint16 uint16
	Valid  bool // Valid is true if Uint16 is not NULL
}

func NewUint16

func NewUint16(i uint16) Uint16

func (*Uint16) Encode

func (ni *Uint16) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Uint16) IsEmpty

func (ni *Uint16) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Uint16) MarshalCSV

func (ni Uint16) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Uint16) MarshalJSON

func (ni Uint16) MarshalJSON() ([]byte, error)

func (*Uint16) Scan

func (ni *Uint16) Scan(value any) error

func (*Uint16) UnmarshalCSV

func (ni *Uint16) UnmarshalCSV(b string) error

func (*Uint16) UnmarshalJSON

func (ni *Uint16) UnmarshalJSON(b []byte) error

func (Uint16) Value

func (ni Uint16) Value() (driver.Value, error)

type Uint32

type Uint32 struct {
	Uint32 uint32
	Valid  bool // Valid is true if Uint32 is not NULL
}

func NewUint32

func NewUint32(i uint32) Uint32

func (*Uint32) Encode

func (ni *Uint32) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Uint32) IsEmpty

func (ni *Uint32) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Uint32) MarshalCSV

func (ni Uint32) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Uint32) MarshalJSON

func (ni Uint32) MarshalJSON() ([]byte, error)

func (*Uint32) Scan

func (ni *Uint32) Scan(value any) error

func (*Uint32) UnmarshalCSV

func (ni *Uint32) UnmarshalCSV(b string) error

func (*Uint32) UnmarshalJSON

func (ni *Uint32) UnmarshalJSON(b []byte) error

func (Uint32) Value

func (ni Uint32) Value() (driver.Value, error)

type Uint64

type Uint64 struct {
	Uint64 uint64
	Valid  bool // Valid is true if Uint64 is not NULL
}

func NewUint64

func NewUint64(i uint64) Uint64

func (*Uint64) Encode

func (ni *Uint64) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Uint64) IsEmpty

func (ni *Uint64) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Uint64) MarshalCSV

func (ni Uint64) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Uint64) MarshalJSON

func (ni Uint64) MarshalJSON() ([]byte, error)

func (*Uint64) Scan

func (ni *Uint64) Scan(value any) error

func (*Uint64) UnmarshalCSV

func (ni *Uint64) UnmarshalCSV(b string) error

func (*Uint64) UnmarshalJSON

func (ni *Uint64) UnmarshalJSON(b []byte) error

func (Uint64) Value

func (ni Uint64) Value() (driver.Value, error)

type Uint8

type Uint8 struct {
	Uint8 uint8
	Valid bool // Valid is true if Uint8 is not NULL
}

func NewUint8

func NewUint8(i uint8) Uint8

func (*Uint8) Encode

func (ni *Uint8) Encode(ptr unsafe.Pointer, stream *jsoniter.Stream)

func (*Uint8) IsEmpty

func (ni *Uint8) IsEmpty(ptr unsafe.Pointer) bool

IsEmpty detect whether primitive.ObjectID is empty.

func (Uint8) MarshalCSV

func (ni Uint8) MarshalCSV() (string, error)

MarshalCSV marshals CSV

func (Uint8) MarshalJSON

func (ni Uint8) MarshalJSON() ([]byte, error)

func (*Uint8) Scan

func (ni *Uint8) Scan(value any) error

func (*Uint8) UnmarshalCSV

func (ni *Uint8) UnmarshalCSV(b string) error

func (*Uint8) UnmarshalJSON

func (ni *Uint8) UnmarshalJSON(b []byte) error

func (Uint8) Value

func (ni Uint8) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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