nan

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 16 Imported by: 3

README

nan - No Allocations Nevermore

Package nan - Zero allocation Nullable structures in one library with handy conversion functions, marshallers and unmarshallers.

Godoc Coverage Status Go Report Card Go

Features:

  • short name "nan"
  • handy conversion functions
  • select which marshalers you want and limit dependencies to only those you actually need
  • ability to convert your custom structs to nan compatible type with Valid field and all requested encoders/decoders

Supported types:

  • bool
  • float32
  • float64
  • int
  • int8
  • int16
  • int32
  • int64
  • string
  • time.Time
  • uint
  • uint8
  • uint16
  • uint32
  • uint64
  • more types will be added as necessary

Supported marshallers:

  • Standart JSON
  • encoding.TextMarshaler/TextUnmarshaler. Reuses standard JSON logic and format
  • jsoniter
  • easyjson
  • go-json
  • Scylla and Cassandra. Compatible with gocql
  • SQL

Usage

Simply create struct field or variable with one of the exported types and use it without any changes to external API.

JSON input/output will be converted to null or non null values. Scylla and Cassandra will use wire format compatible with gocql.

	var data struct {
		Code nan.NullString `json:"code"`
	}

	b, err := jsoniter.Marshal(data)
	if err != nil {
		panic(err)
	}

	// {"code":null}
	fmt.Println(string(b))

	data.Code = nan.String("1")
	// Equals to
	// data.Code = nan.NullString{String: "1", Valid: true}

	b, err = jsoniter.Marshal(data)
	if err != nil {
		panic(err)
	}

	// {"code":"1"}
	fmt.Println(string(b))

  code := "2"

  // From addr. Can has value or be nil
  data.Code = nan.StringAddr(&code)

	b, err = jsoniter.Marshal(data)
	if err != nil {
		panic(err)
	}

	// {"code":"2"}
	fmt.Println(string(b))

  // To usual value from nan
  codeVal := data.Code.String

  // 2
  fmt.Println(codeVal)

  // To value addr from nan
  codeAddr := data.Code.Addr()

  // 2
  fmt.Println(*codeAddr)

Generate marshalers

# go install github.com/kak-tus/nan/cmd/nan@latest
# nan -help

Instead of depending on the whole github.com/kak-tus/nan you can also use nan command to select which marshalers you want. Simply run nan with one or more arguments and it will generate implementations for the specified marshalers in the current directory. For example, running

# nan gen -json -jsoniter

will generate nan.go, json.go, jsoniter.go files in the current working directory that contain only encoding/json and jsoniter marshalers. Nothing else will be generated so you don't have to depend on all the marshalers that github.com/kak-tus/nan supports. Generated files will use current directory name as its package name. You can also specify your own package name with -pkg argument.

Custom structs generator

Imagine, that you have custom struct

type MyStruct struct {
	ID   int
	Name string
}

Use nan command on its file

# nan extra -json -jsoniter example/structs.go

This will generate *_nan.go near source files with json (or any other supported marshallers). And now you have nan compatible struct with all needed marshallers

var val MyStruct

nullVal := NanMyStruct(val)
// Equals to
// nullVal := NullMyStruct{MyStruct: val, Valid: true}

fmt.Println(nullVal.ID)

See example to specific of easyjson, cql, sql generation.

nan extra coommand supports any number of file names at command line.

Benchmarks

See here.

sqlc integration

See here.

Documentation

Overview

Package nan - Zero allocation Nullable structures in one library with handy conversion functions, marshallers and unmarshallers.

Features: - short name "nan" - handy conversion functions - select which marshalers you want and limit dependencies to only those you actually need - ability to convert your custom structs to nan compatible type with Valid field and all requested encoders/decoders

Supported types: - bool - float32 - float64 - int - int8 - int16 - int32 - int64 - string - time.Time - more types will be added as necessary

Supported marshallers: - Standart JSON - encoding.TextMarshaler/TextUnmarshaler. Reuses standard JSON logic and format - jsoniter - easyjson - go-json - Scylla and Cassandra. Compatible with gocql - SQL

Usage

Simply create struct field or variable with one of the exported types and use it without any changes to external API.

JSON input/output will be converted to null or non null values. Scylla and Cassandra will use wire format compatible with gocql.

	var data struct {
		Code nan.NullString `json:"code"`
	}

	b, err := jsoniter.Marshal(data)
	if err != nil {
		panic(err)
	}

	// {"code":null}
	fmt.Println(string(b))

	data.Code = nan.String("1")
	// Equals to
	// data.Code = nan.NullString{String: "1", Valid: true}

	b, err = jsoniter.Marshal(data)
	if err != nil {
		panic(err)
	}

	// {"code":"1"}
	fmt.Println(string(b))

  code := "2"

  // From addr. Can has value or be nil
  data.Code = nan.StringAddr(&code)

	b, err = jsoniter.Marshal(data)
	if err != nil {
		panic(err)
	}

	// {"code":"2"}
	fmt.Println(string(b))

  // To usual value from nan
  codeVal := data.Code.String

  // 2
  fmt.Println(codeVal)

  // To value addr from nan
  codeAddr := data.Code.Addr()

  // 2
  fmt.Println(*codeAddr)

Index

Constants

This section is empty.

Variables

View Source
var EmbeddedSources embed.FS

Functions

This section is empty.

Types

type NullBool

type NullBool struct {
	Bool  bool
	Valid bool // Valid is true if Bool is not NULL
}

NullBool - nullable bool

func Bool added in v0.1.9

func Bool(v bool) NullBool

Bool - converts bool to NullBool

func BoolAddr added in v0.8.0

func BoolAddr(v *bool) NullBool

BoolAddr - converts bool address to NullBool

func BoolToNullBool deprecated

func BoolToNullBool(v bool) NullBool

BoolToNullBool - converts bool to NullBool

Deprecated: use shorter variant

func (NullBool) Addr added in v0.7.0

func (n NullBool) Addr() *bool

func (NullBool) IsDefined added in v0.1.10

func (n NullBool) IsDefined() bool

func (NullBool) IsValid added in v0.1.7

func (n NullBool) IsValid() bool

func (NullBool) MarshalCQL

func (n NullBool) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullBool) MarshalEasyJSON

func (n NullBool) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullBool) MarshalJSON

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

MarshalJSON - marshaller for json

func (NullBool) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullBool) Scan added in v0.1.5

func (n *NullBool) Scan(value interface{}) error

Scan - scan value from sql driver

func (*NullBool) UnmarshalCQL

func (n *NullBool) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullBool) UnmarshalEasyJSON

func (n *NullBool) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullBool) UnmarshalJSON

func (n *NullBool) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullBool) UnmarshalText added in v0.4.0

func (n *NullBool) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullBool) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullFloat32 added in v0.1.2

type NullFloat32 struct {
	Float32 float32
	Valid   bool // Valid is true if Float32 is not NULL
}

NullFloat32 - nullable float32

func Float32 added in v0.1.9

func Float32(v float32) NullFloat32

Float32 - converts float32 to NullFloat32

func Float32Addr added in v0.8.0

func Float32Addr(v *float32) NullFloat32

Float32Addr - converts float32 address to NullFloat32

func Float32ToNullFloat32 deprecated added in v0.1.3

func Float32ToNullFloat32(v float32) NullFloat32

Float32ToNullFloat32 - converts float32 to NullFloat32

Deprecated: use shorter variant

func (NullFloat32) Addr added in v0.7.0

func (n NullFloat32) Addr() *float32

func (NullFloat32) IsDefined added in v0.1.10

func (n NullFloat32) IsDefined() bool

func (NullFloat32) IsValid added in v0.1.7

func (n NullFloat32) IsValid() bool

func (NullFloat32) MarshalCQL added in v0.1.2

func (n NullFloat32) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullFloat32) MarshalEasyJSON added in v0.1.2

func (n NullFloat32) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullFloat32) MarshalJSON added in v0.1.2

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

MarshalJSON - marshaller for json

func (NullFloat32) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullFloat32) Scan added in v0.1.5

func (n *NullFloat32) Scan(value interface{}) error

Scan - scan value from sql driver

func (*NullFloat32) UnmarshalCQL added in v0.1.2

func (n *NullFloat32) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullFloat32) UnmarshalEasyJSON added in v0.1.2

func (n *NullFloat32) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullFloat32) UnmarshalJSON added in v0.1.2

func (n *NullFloat32) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullFloat32) UnmarshalText added in v0.4.0

func (n *NullFloat32) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullFloat32) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullFloat64 added in v0.1.1

type NullFloat64 struct {
	Float64 float64
	Valid   bool // Valid is true if Float64 is not NULL
}

NullFloat64 - nullable float64

func Float64 added in v0.1.9

func Float64(v float64) NullFloat64

Float64 - converts float64 to NullFloat64

func Float64Addr added in v0.8.0

func Float64Addr(v *float64) NullFloat64

Float64Addr - converts float64 address to NullFloat64

func Float64ToNullFloat64 deprecated added in v0.1.1

func Float64ToNullFloat64(v float64) NullFloat64

Float64ToNullFloat64 - converts float64 to NullFloat64

Deprecated: use shorter variant

func (NullFloat64) Addr added in v0.7.0

func (n NullFloat64) Addr() *float64

func (NullFloat64) IsDefined added in v0.1.10

func (n NullFloat64) IsDefined() bool

func (NullFloat64) IsValid added in v0.1.7

func (n NullFloat64) IsValid() bool

func (NullFloat64) MarshalCQL added in v0.1.1

func (n NullFloat64) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullFloat64) MarshalEasyJSON added in v0.1.1

func (n NullFloat64) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullFloat64) MarshalJSON added in v0.1.1

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

MarshalJSON - marshaller for json

func (NullFloat64) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullFloat64) Scan added in v0.1.5

func (n *NullFloat64) Scan(value interface{}) error

Scan - scan value from sql driver

func (*NullFloat64) UnmarshalCQL added in v0.1.1

func (n *NullFloat64) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullFloat64) UnmarshalEasyJSON added in v0.1.1

func (n *NullFloat64) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullFloat64) UnmarshalJSON added in v0.1.1

func (n *NullFloat64) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullFloat64) UnmarshalText added in v0.4.0

func (n *NullFloat64) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullFloat64) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullInt added in v0.1.4

type NullInt struct {
	Int   int
	Valid bool // Valid is true if Int is not NULL
}

NullInt - nullable int

func Int added in v0.1.9

func Int(v int) NullInt

Int - converts int to NullInt

func IntAddr added in v0.8.0

func IntAddr(v *int) NullInt

IntAddr - converts int address to NullInt

func IntToNullInt deprecated added in v0.1.5

func IntToNullInt(v int) NullInt

IntToNullInt - converts int to NullInt

Deprecated: use shorter variant

func (NullInt) Addr added in v0.7.0

func (n NullInt) Addr() *int

func (NullInt) IsDefined added in v0.1.10

func (n NullInt) IsDefined() bool

func (NullInt) IsValid added in v0.1.7

func (n NullInt) IsValid() bool

func (NullInt) MarshalCQL added in v0.1.4

func (n NullInt) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullInt) MarshalEasyJSON added in v0.1.4

func (n NullInt) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullInt) MarshalJSON added in v0.1.4

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

MarshalJSON - marshaller for json

func (NullInt) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullInt) Scan added in v0.1.5

func (n *NullInt) Scan(value interface{}) error

Scan - scan value from sql driver

func (*NullInt) UnmarshalCQL added in v0.1.4

func (n *NullInt) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullInt) UnmarshalEasyJSON added in v0.1.4

func (n *NullInt) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullInt) UnmarshalJSON added in v0.1.4

func (n *NullInt) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullInt) UnmarshalText added in v0.4.0

func (n *NullInt) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullInt) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullInt16 added in v0.1.2

type NullInt16 struct {
	Int16 int16
	Valid bool // Valid is true if Int16 is not NULL
}

NullInt16 - nullable int16

func Int16 added in v0.1.9

func Int16(v int16) NullInt16

Int16 - converts int16 to NullInt16

func Int16Addr added in v0.8.0

func Int16Addr(v *int16) NullInt16

Int16Addr - converts int16 address to NullInt16

func Int16ToNullInt16 deprecated added in v0.1.3

func Int16ToNullInt16(v int16) NullInt16

Int16ToNullInt16 - converts int16 to NullInt16

Deprecated: use shorter variant

func (NullInt16) Addr added in v0.7.0

func (n NullInt16) Addr() *int16

func (NullInt16) IsDefined added in v0.1.10

func (n NullInt16) IsDefined() bool

func (NullInt16) IsValid added in v0.1.7

func (n NullInt16) IsValid() bool

func (NullInt16) MarshalCQL added in v0.1.2

func (n NullInt16) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullInt16) MarshalEasyJSON added in v0.1.2

func (n NullInt16) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullInt16) MarshalJSON added in v0.1.2

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

MarshalJSON - marshaller for json

func (NullInt16) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullInt16) Scan added in v0.1.5

func (n *NullInt16) Scan(value interface{}) error

Scan - scan value from sql driver

func (*NullInt16) UnmarshalCQL added in v0.1.2

func (n *NullInt16) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullInt16) UnmarshalEasyJSON added in v0.1.2

func (n *NullInt16) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullInt16) UnmarshalJSON added in v0.1.2

func (n *NullInt16) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullInt16) UnmarshalText added in v0.4.0

func (n *NullInt16) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullInt16) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullInt32 added in v0.1.2

type NullInt32 struct {
	Int32 int32
	Valid bool // Valid is true if Int32 is not NULL
}

NullInt32 - nullable int32

func Int32 added in v0.1.9

func Int32(v int32) NullInt32

Int32 - converts int32 to NullInt32

func Int32Addr added in v0.8.0

func Int32Addr(v *int32) NullInt32

Int32Addr - converts int32 address to NullInt32

func Int32ToNullInt32 deprecated added in v0.1.3

func Int32ToNullInt32(v int32) NullInt32

Int32ToNullInt32 - converts int32 to NullInt32

Deprecated: use shorter variant

func (NullInt32) Addr added in v0.7.0

func (n NullInt32) Addr() *int32

func (NullInt32) IsDefined added in v0.1.10

func (n NullInt32) IsDefined() bool

func (NullInt32) IsValid added in v0.1.7

func (n NullInt32) IsValid() bool

func (NullInt32) MarshalCQL added in v0.1.2

func (n NullInt32) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullInt32) MarshalEasyJSON added in v0.1.2

func (n NullInt32) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullInt32) MarshalJSON added in v0.1.2

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

MarshalJSON - marshaller for json

func (NullInt32) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullInt32) Scan added in v0.1.5

func (n *NullInt32) Scan(value interface{}) error

Scan - scan value from sql driver

func (*NullInt32) UnmarshalCQL added in v0.1.2

func (n *NullInt32) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullInt32) UnmarshalEasyJSON added in v0.1.2

func (n *NullInt32) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullInt32) UnmarshalJSON added in v0.1.2

func (n *NullInt32) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullInt32) UnmarshalText added in v0.4.0

func (n *NullInt32) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullInt32) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullInt64

type NullInt64 struct {
	Int64 int64
	Valid bool // Valid is true if Int64 is not NULL
}

NullInt64 - nullable int64

func Int64 added in v0.1.9

func Int64(v int64) NullInt64

Int64 - converts int64 to NullInt64

func Int64Addr added in v0.8.0

func Int64Addr(v *int64) NullInt64

Int64Addr - converts int64 address to NullInt64

func Int64ToNullInt64 deprecated

func Int64ToNullInt64(v int64) NullInt64

Int64ToNullInt64 - converts int64 to NullInt64

Deprecated: use shorter variant

func (NullInt64) Addr added in v0.7.0

func (n NullInt64) Addr() *int64

func (NullInt64) IsDefined added in v0.1.10

func (n NullInt64) IsDefined() bool

func (NullInt64) IsValid added in v0.1.7

func (n NullInt64) IsValid() bool

func (NullInt64) MarshalCQL

func (n NullInt64) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullInt64) MarshalEasyJSON

func (n NullInt64) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullInt64) MarshalJSON

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

MarshalJSON - marshaller for json

func (NullInt64) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullInt64) Scan added in v0.1.5

func (n *NullInt64) Scan(value interface{}) error

Scan - scan value from sql driver

func (*NullInt64) UnmarshalCQL

func (n *NullInt64) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullInt64) UnmarshalEasyJSON

func (n *NullInt64) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullInt64) UnmarshalJSON

func (n *NullInt64) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullInt64) UnmarshalText added in v0.4.0

func (n *NullInt64) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullInt64) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullInt8 added in v0.1.2

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

NullInt8 - nullable int8

func Int8 added in v0.1.9

func Int8(v int8) NullInt8

Int8 - converts int8 to NullInt8

func Int8Addr added in v0.8.0

func Int8Addr(v *int8) NullInt8

Int8Addr - converts int8 address to NullInt8

func Int8ToNullInt8 deprecated added in v0.1.3

func Int8ToNullInt8(v int8) NullInt8

Int8ToNullInt8 - converts int8 to NullInt8

Deprecated: use shorter variant

func (NullInt8) Addr added in v0.7.0

func (n NullInt8) Addr() *int8

func (NullInt8) IsDefined added in v0.1.10

func (n NullInt8) IsDefined() bool

func (NullInt8) IsValid added in v0.1.7

func (n NullInt8) IsValid() bool

func (NullInt8) MarshalCQL added in v0.1.2

func (n NullInt8) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullInt8) MarshalEasyJSON added in v0.1.2

func (n NullInt8) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullInt8) MarshalJSON added in v0.1.2

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

MarshalJSON - marshaller for json

func (NullInt8) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullInt8) Scan added in v0.1.5

func (n *NullInt8) Scan(value interface{}) error

Scan - scan value from sql driver

func (*NullInt8) UnmarshalCQL added in v0.1.2

func (n *NullInt8) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullInt8) UnmarshalEasyJSON added in v0.1.2

func (n *NullInt8) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullInt8) UnmarshalJSON added in v0.1.2

func (n *NullInt8) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullInt8) UnmarshalText added in v0.4.0

func (n *NullInt8) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullInt8) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullString

type NullString struct {
	String string
	Valid  bool // Valid is true if String is not NULL
}

NullString - nullable string

func String added in v0.1.9

func String(v string) NullString

String - converts string to NullString

func StringAddr added in v0.8.0

func StringAddr(v *string) NullString

StringAddr - converts string address to NullString

func StringToNullString deprecated

func StringToNullString(v string) NullString

StringToNullString - converts string to NullString

Deprecated: use shorter variant

func (NullString) Addr added in v0.7.0

func (n NullString) Addr() *string

func (NullString) IsDefined added in v0.1.10

func (n NullString) IsDefined() bool

func (NullString) IsValid added in v0.1.7

func (n NullString) IsValid() bool

func (NullString) MarshalCQL

func (n NullString) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullString) MarshalEasyJSON

func (n NullString) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullString) MarshalJSON

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

MarshalJSON - marshaller for json

func (NullString) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullString) Scan added in v0.1.5

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

Scan - scan value from sql driver

func (*NullString) UnmarshalCQL

func (n *NullString) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullString) UnmarshalEasyJSON

func (n *NullString) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullString) UnmarshalJSON

func (n *NullString) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullString) UnmarshalText added in v0.4.0

func (n *NullString) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullString) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

NullTime - nullable time.Time

func Time added in v0.1.9

func Time(v time.Time) NullTime

Time - converts time.Time to NullTime

func TimeAddr added in v0.8.0

func TimeAddr(v *time.Time) NullTime

TimeAddr - converts time.Time address to NullTime

func TimeToNullTime deprecated

func TimeToNullTime(v time.Time) NullTime

TimeToNullTime - converts time.Time to NullTime

Deprecated: use shorter variant

func (NullTime) Addr added in v0.7.0

func (n NullTime) Addr() *time.Time

func (NullTime) IsDefined added in v0.1.10

func (n NullTime) IsDefined() bool

func (NullTime) IsValid added in v0.1.7

func (n NullTime) IsValid() bool

func (NullTime) MarshalCQL

func (n NullTime) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL - marshaller for cql

func (NullTime) MarshalEasyJSON

func (n NullTime) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullTime) MarshalJSON

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

MarshalJSON - marshaller for json

func (NullTime) MarshalText added in v0.4.0

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

MarshalText - marshaller for text

func (*NullTime) Scan added in v0.1.5

func (n *NullTime) Scan(value interface{}) error

Scan - scan value from sql driver

func (*NullTime) UnmarshalCQL

func (n *NullTime) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL - unmarshaller for cql

func (*NullTime) UnmarshalEasyJSON

func (n *NullTime) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullTime) UnmarshalJSON

func (n *NullTime) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullTime) UnmarshalText added in v0.4.0

func (n *NullTime) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

func (NullTime) Value added in v0.1.5

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

Value implements the driver Valuer interface.

type NullUint added in v0.9.0

type NullUint struct {
	Uint  uint
	Valid bool // Valid is true if Uint is not NULL
}

NullUint - nullable uint

func Uint added in v0.9.0

func Uint(v uint) NullUint

Uint - converts uint to NullUint

func UintAddr added in v0.9.0

func UintAddr(v *uint) NullUint

UintAddr - converts uint address to NullUint

func (NullUint) Addr added in v0.9.0

func (n NullUint) Addr() *uint

func (NullUint) IsDefined added in v0.9.0

func (n NullUint) IsDefined() bool

func (NullUint) IsValid added in v0.9.0

func (n NullUint) IsValid() bool

func (NullUint) MarshalEasyJSON added in v0.9.0

func (n NullUint) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullUint) MarshalJSON added in v0.9.0

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

MarshalJSON - marshaller for json

func (NullUint) MarshalText added in v0.9.0

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

MarshalText - marshaller for text

func (*NullUint) UnmarshalEasyJSON added in v0.9.0

func (n *NullUint) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullUint) UnmarshalJSON added in v0.9.0

func (n *NullUint) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullUint) UnmarshalText added in v0.9.0

func (n *NullUint) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

type NullUint16 added in v0.9.0

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

NullUint16 - nullable uint16

func Uint16 added in v0.9.0

func Uint16(v uint16) NullUint16

Uint16 - converts uint16 to NullUint16

func Uint16Addr added in v0.9.0

func Uint16Addr(v *uint16) NullUint16

Uint16Addr - converts uint16 address to NullUint16

func (NullUint16) Addr added in v0.9.0

func (n NullUint16) Addr() *uint16

func (NullUint16) IsDefined added in v0.9.0

func (n NullUint16) IsDefined() bool

func (NullUint16) IsValid added in v0.9.0

func (n NullUint16) IsValid() bool

func (NullUint16) MarshalEasyJSON added in v0.9.0

func (n NullUint16) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullUint16) MarshalJSON added in v0.9.0

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

MarshalJSON - marshaller for json

func (NullUint16) MarshalText added in v0.9.0

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

MarshalText - marshaller for text

func (*NullUint16) UnmarshalEasyJSON added in v0.9.0

func (n *NullUint16) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullUint16) UnmarshalJSON added in v0.9.0

func (n *NullUint16) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullUint16) UnmarshalText added in v0.9.0

func (n *NullUint16) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

type NullUint32 added in v0.9.0

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

NullUint32 - nullable uint32

func Uint32 added in v0.9.0

func Uint32(v uint32) NullUint32

Uint32 - converts uint32 to NullUint32

func Uint32Addr added in v0.9.0

func Uint32Addr(v *uint32) NullUint32

Uint32Addr - converts uint32 address to NullUint32

func (NullUint32) Addr added in v0.9.0

func (n NullUint32) Addr() *uint32

func (NullUint32) IsDefined added in v0.9.0

func (n NullUint32) IsDefined() bool

func (NullUint32) IsValid added in v0.9.0

func (n NullUint32) IsValid() bool

func (NullUint32) MarshalEasyJSON added in v0.9.0

func (n NullUint32) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullUint32) MarshalJSON added in v0.9.0

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

MarshalJSON - marshaller for json

func (NullUint32) MarshalText added in v0.9.0

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

MarshalText - marshaller for text

func (*NullUint32) UnmarshalEasyJSON added in v0.9.0

func (n *NullUint32) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullUint32) UnmarshalJSON added in v0.9.0

func (n *NullUint32) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullUint32) UnmarshalText added in v0.9.0

func (n *NullUint32) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

type NullUint64 added in v0.9.0

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

NullUint64 - nullable uint64

func Uint64 added in v0.9.0

func Uint64(v uint64) NullUint64

Uint64 - converts uint64 to NullUint64

func Uint64Addr added in v0.9.0

func Uint64Addr(v *uint64) NullUint64

Uint64Addr - converts uint64 address to NullUint64

func (NullUint64) Addr added in v0.9.0

func (n NullUint64) Addr() *uint64

func (NullUint64) IsDefined added in v0.9.0

func (n NullUint64) IsDefined() bool

func (NullUint64) IsValid added in v0.9.0

func (n NullUint64) IsValid() bool

func (NullUint64) MarshalEasyJSON added in v0.9.0

func (n NullUint64) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullUint64) MarshalJSON added in v0.9.0

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

MarshalJSON - marshaller for json

func (NullUint64) MarshalText added in v0.9.0

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

MarshalText - marshaller for text

func (*NullUint64) UnmarshalEasyJSON added in v0.9.0

func (n *NullUint64) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullUint64) UnmarshalJSON added in v0.9.0

func (n *NullUint64) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullUint64) UnmarshalText added in v0.9.0

func (n *NullUint64) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

type NullUint8 added in v0.9.0

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

NullUint8 - nullable uint8

func Uint8 added in v0.9.0

func Uint8(v uint8) NullUint8

Uint8 - converts uint8 to NullUint8

func Uint8Addr added in v0.9.0

func Uint8Addr(v *uint8) NullUint8

Uint8Addr - converts uint8 address to NullUint8

func (NullUint8) Addr added in v0.9.0

func (n NullUint8) Addr() *uint8

func (NullUint8) IsDefined added in v0.9.0

func (n NullUint8) IsDefined() bool

func (NullUint8) IsValid added in v0.9.0

func (n NullUint8) IsValid() bool

func (NullUint8) MarshalEasyJSON added in v0.9.0

func (n NullUint8) MarshalEasyJSON(out *jwriter.Writer)

MarshalEasyJSON - marshaller for easyjson

func (NullUint8) MarshalJSON added in v0.9.0

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

MarshalJSON - marshaller for json

func (NullUint8) MarshalText added in v0.9.0

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

MarshalText - marshaller for text

func (*NullUint8) UnmarshalEasyJSON added in v0.9.0

func (n *NullUint8) UnmarshalEasyJSON(in *jlexer.Lexer)

UnmarshalEasyJSON - unmarshaller for easyjson

func (*NullUint8) UnmarshalJSON added in v0.9.0

func (n *NullUint8) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmarshaller for json

func (*NullUint8) UnmarshalText added in v0.9.0

func (n *NullUint8) UnmarshalText(text []byte) error

UnmarshalText - unmarshaller for text

type Validator added in v0.1.7

type Validator interface {
	IsValid() bool
}

Validator is implemented by all nan types and returns Valid field

Directories

Path Synopsis
cmd
nan

Jump to

Keyboard shortcuts

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