null

package module
v0.0.0-...-fae4cde Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 5 Imported by: 0

README

go-null

Test application

Simple and lightweight library for working with sql null values

Installation

go get github.com/abdivasiyev/go-null

Usage

package main

import (
	"github.com/abdivasiyev/go-null"
	"fmt"
	"database/sql"
)

type User struct {
	ID        int         `json:"id"`
	Firstname string      `json:"firstname"`
	Lastname  null.String `json:"lastname"`
	Age       null.Int    `json:"age"`
}

func main() {
	var u User
	// some stuff with sql

	if err := row.Scan(
		&u.ID,
		&u.Firstname,
		&u.Lastname,
		&u.Age,
	); err != nil {
		panic(err)
	}

	fmt.Println(u.ID, u.Firstname, u.Lastname.Get(), u.Age.Get())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

func NewBool

func NewBool(value bool) *Bool

func (*Bool) Get

func (s *Bool) Get() bool

func (Bool) MarshalJSON

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

func (*Bool) Scan

func (s *Bool) Scan(value any) error

func (*Bool) String

func (s *Bool) String() string

func (*Bool) UnmarshalJSON

func (s *Bool) UnmarshalJSON(bytes []byte) error

func (*Bool) Value

func (s *Bool) Value() (driver.Value, error)

type Byte

type Byte struct {
	// contains filtered or unexported fields
}

func NewByte

func NewByte(value byte) *Byte

func (Byte) Get

func (s Byte) Get() byte

func (Byte) MarshalJSON

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

func (*Byte) Scan

func (s *Byte) Scan(value any) error

func (Byte) String

func (s Byte) String() string

func (*Byte) UnmarshalJSON

func (s *Byte) UnmarshalJSON(bytes []byte) error

func (Byte) Value

func (s Byte) Value() (driver.Value, error)

type Float32

type Float32 struct {
	// contains filtered or unexported fields
}

func NewFloat32

func NewFloat32(value float32) *Float32

func (Float32) Get

func (s Float32) Get() float32

func (Float32) MarshalJSON

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

func (*Float32) Scan

func (s *Float32) Scan(value any) error

func (Float32) String

func (s Float32) String() string

func (*Float32) UnmarshalJSON

func (s *Float32) UnmarshalJSON(bytes []byte) error

func (Float32) Value

func (s Float32) Value() (driver.Value, error)

type Float64

type Float64 struct {
	// contains filtered or unexported fields
}

func NewFloat64

func NewFloat64(value float64) *Float64

func (Float64) Get

func (s Float64) Get() float64

func (Float64) MarshalJSON

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

func (*Float64) Scan

func (s *Float64) Scan(value any) error

func (Float64) String

func (s Float64) String() string

func (*Float64) UnmarshalJSON

func (s *Float64) UnmarshalJSON(bytes []byte) error

func (*Float64) Value

func (s *Float64) Value() (driver.Value, error)

type Int

type Int struct {
	// contains filtered or unexported fields
}

func NewInt

func NewInt(value int) *Int

func (Int) Get

func (s Int) Get() int

func (Int) MarshalJSON

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

func (*Int) Scan

func (s *Int) Scan(value any) error

func (Int) String

func (s Int) String() string

func (*Int) UnmarshalJSON

func (s *Int) UnmarshalJSON(bytes []byte) error

func (Int) Value

func (s Int) Value() (driver.Value, error)

type Int16

type Int16 struct {
	// contains filtered or unexported fields
}

func NewInt16

func NewInt16(value int16) *Int16

func (Int16) Get

func (s Int16) Get() int16

func (Int16) MarshalJSON

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

func (*Int16) Scan

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

func (Int16) String

func (s Int16) String() string

func (*Int16) UnmarshalJSON

func (s *Int16) UnmarshalJSON(bytes []byte) error

func (Int16) Value

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

type Int32

type Int32 struct {
	// contains filtered or unexported fields
}

func NewInt32

func NewInt32(value int32) *Int32

func (Int32) Get

func (s Int32) Get() int32

func (Int32) MarshalJSON

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

func (*Int32) Scan

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

func (Int32) String

func (s Int32) String() string

func (*Int32) UnmarshalJSON

func (s *Int32) UnmarshalJSON(bytes []byte) error

func (Int32) Value

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

type Int64

type Int64 struct {
	// contains filtered or unexported fields
}

func NewInt64

func NewInt64(value int64) *Int64

func (Int64) Get

func (s Int64) Get() int64

func (Int64) MarshalJSON

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

func (*Int64) Scan

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

func (Int64) String

func (s Int64) String() string

func (*Int64) UnmarshalJSON

func (s *Int64) UnmarshalJSON(bytes []byte) error

func (Int64) Value

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

type String

type String struct {
	// contains filtered or unexported fields
}

func NewString

func NewString(value string) *String

func (String) Get

func (s String) Get() string

func (String) MarshalJSON

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

func (*String) Scan

func (s *String) Scan(value any) error

func (String) String

func (s String) String() string

func (*String) UnmarshalJSON

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

func (String) Value

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

type Time

type Time struct {
	// contains filtered or unexported fields
}

func NewTime

func NewTime(value time.Time) *Time

func (Time) Get

func (s Time) Get() time.Time

func (Time) MarshalJSON

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

func (*Time) Scan

func (s *Time) Scan(value any) error

func (Time) String

func (s Time) String() string

func (*Time) UnmarshalJSON

func (s *Time) UnmarshalJSON(bytes []byte) error

func (Time) Value

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

Jump to

Keyboard shortcuts

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