db_common

package
v0.0.0-...-e50888d Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NullInt

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

NullInt represents an int that may be null. NullInt implements the Scanner interface so it can be used as a scan destination, similar to NullString.

func (NullInt) MarshalJSON

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

MarshalJSON implements the encoding/json.Marshaler interface.

func (*NullInt) Scan

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

Scan implements the Scanner interface.

func (*NullInt) UnmarshalJSON

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

UnmarshalJSON implements the encoding/json.Unmarshaler interface.

func (NullInt) Value

func (n NullInt) 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
}

func Now

func Now() NullTime

Now returns a valid NullTime with the time set to now, in UTC and rounded to the nearest millisecond. It does this so that JSON- and SQL-serialization and deserialization yields the same time as passed in. If the time is not UTC or has sub-millisecond accuracy, the time retrieved from an SQL DB or JSON object might not be equal to the original object due to rounding and automatic timezone conversion.

func (NullTime) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

func (*NullTime) Scan

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

Scan implements the Scanner interface.

func (NullTime) String

func (nt NullTime) String() string

func (*NullTime) UnmarshalJSON

func (nt *NullTime) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface.

func (NullTime) Value

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

Value implements the driver Valuer interface.

type StringSlice

type StringSlice struct {
	Slice []string
}

func NewSlice

func NewSlice(goslice []string) *StringSlice

func (*StringSlice) Scan

func (s *StringSlice) Scan(v interface{}) error

func (*StringSlice) Value

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

Jump to

Keyboard shortcuts

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