Skip to content

mobyfox/null

Repository files navigation

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.

About

A zero dependency library to handle SQL nullable values

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages