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 6, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

README

null

coverage version

A zero dependency library to handle SQL nullable values.

Contents

Installation

  1. You can use the below command to install null.
$ go get -u github.com/mobyfox/null
  1. Import it in your code
import "github.com/mobyfox/null"

Null

null.Bool

Nullable bool.

Marshals to JSON null if data coming from SQL is null. False will not produce a null Bool.

type Example struct {
    Bool null.Bool `json:"bool"`
}
null.Byte

Nullable byte.

Marshals to JSON null if data coming from SQL is null. Blank input will not produce a null Byte.

type Example struct {
    Byte null.Byte `json:"byte"`
}
null.Float64

Nullable float64.

Marshals to JSON null if data coming from SQL is null. Zero input will not produce a null Float64.

type Example struct {
    Float64 null.Float64 `json:"float64"`
}
null.Int16

Nullable int16.

Marshals to JSON null if data coming from SQL is null. Zero input will not produce a null Int16.

type Example struct {
    Int16 null.Int16 `json:"int16"`
}
null.Int32

Nullable int32.

Marshals to JSON null if data coming from SQL is null. Zero input will not produce a null Int32.

type Example struct {
    Int32 null.Int32 `json:"int32"`
}
null.Int64

Nullable int64.

Marshals to JSON null if data coming from SQL is null. Zero input will not produce a null Int64.

type Example struct {
    Int64 null.Int64 `json:"int64"`
}
null.String

Nullable string.

Marshals to JSON null if data coming from SQL is null. Blank input will not produce a null String.

type Example struct {
    String null.String `json:"string"`
}
null.Time

Nullable time.

Marshals to JSON null if data coming from SQL is null. Blank input will not produce a null Time.

type Example struct {
    Time null.Time `json:"time"`
}

License

This project utilizes the Apache License 2.0 please do read the permissions, conditions and limitations before using this library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	sql.NullBool
}

Bool is a custom type that embeds sql.NullBool.

func (Bool) MarshalJSON

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

MarshalJSON uses the Bool custom type and implements the json.Marshaler interface.

type Byte

type Byte struct {
	sql.NullByte
}

Byte is a custom type that embeds sql.NullByte.

func (Byte) MarshalJSON

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

MarshalJSON uses the Byte custom type and implements the json.Marshaler interface.

type Float64

type Float64 struct {
	sql.NullFloat64
}

Float64 is a custom type that embeds sql.NullFloat64

func (Float64) MarshalJSON

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

MarshalJSON uses the Float64 custom type and implements the json.Marshaler interface.

type Int16

type Int16 struct {
	sql.NullInt16
}

Int16 is a custom type that embeds sql.NullInt16.

func (Int16) MarshalJSON

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

MarshalJSON uses the Int16 custom type and implements the json.Marshaler interface.

type Int32

type Int32 struct {
	sql.NullInt32
}

Int32 is a custom type that embeds sql.NullInt32.

func (Int32) MarshalJSON

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

MarshalJSON uses the Int32 custom type and implements the json.Marshaler interface.

type Int64

type Int64 struct {
	sql.NullInt64
}

Int64 is a custom type that embeds sql.NullInt64.

func (Int64) MarshalJSON

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

MarshalJSON uses the Int64 custom type and implements the json.Marshaler interface.

type String

type String struct {
	sql.NullString
}

String is a custom type that embeds sql.NullString.

func (String) MarshalJSON

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

MarshalJSON uses the String custom type and implements the json.Marshaler interface.

type Time

type Time struct {
	sql.NullTime
}

Time is a custom type that embeds sql.NullTime.

func (Time) MarshalJSON

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

MarshalJSON uses the Time custom type and implements the json.Marshaler interface.

Jump to

Keyboard shortcuts

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