nullables

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

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

Go to latest
Published: Nov 21, 2015 License: MIT Imports: 7 Imported by: 6

README

nullables

JSON, gorilla/schema, and SQL-ready Nullable variable types for Golang.

Documentation

Index

Constants

View Source
const (
	HTMLFormTime24Hr       = "15:04"
	HTMLFormTime12Hr       = "3:04 PM"
	HTMLFormDate           = "2006-01-02"
	NZHTMLFormDate         = "02-01-2006"
	NZHTMLFormDateTime12Hr = "02-01-2006 3:04 PM"
	DBTime                 = "15:04:05:000"
	HTMLFormDateTime24Hr   = "2006-01-02 15:04"
	DBDateTime             = "2006-01-02 15:04:05:000"
	TimeWithSeconds        = "15:04:05"
)

Variables

This section is empty.

Functions

func ConvertBool

func ConvertBool(value string) reflect.Value

func NullBoolConverter

func NullBoolConverter(i string) reflect.Value

func NullFloat64Converter

func NullFloat64Converter(i string) reflect.Value

func NullInt64Converter

func NullInt64Converter(i string) reflect.Value

func NullStringConverter

func NullStringConverter(s string) reflect.Value

This function is used to convert an HTML form value (returned from a create or edit, for instance) to a NullTime. It will first try parse it as a Time, if that does not work it will parse it as a Date.

func NullTimeConverter

func NullTimeConverter(b string) reflect.Value

This function is used to convert an HTML form value (returned from a create or edit, for instance) to a NullTime. It will first try parse it as a Time, if that does not work it will parse it as a Date, if that doesn't work it will parse it as a datetime

Types

type NullBool

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

func (NullBool) MarshalJSON

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

this function is used when JSON tries to marshal this struct. Without it it will be marshalled into a JSON object with fields Time and Valid. This is far more elegant.

func (*NullBool) Scan

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

Scan implements the Scanner interface.

func (*NullBool) UnmarshalJSON

func (nt *NullBool) UnmarshalJSON(b []byte) error

func (NullBool) Value

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

Value implements the driver Valuer interface.

type NullFloat64

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

func (NullFloat64) MarshalJSON

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

this function is used when JSON tries to marshal this struct. Without it it will be marshalled into a JSON object with fields Time and Valid. This is far more elegant.

func (*NullFloat64) Scan

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

Scan implements the Scanner interface.

func (*NullFloat64) UnmarshalJSON

func (nt *NullFloat64) UnmarshalJSON(b []byte) error

func (NullFloat64) Value

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

Value implements the driver Valuer interface.

type NullInt64

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

func (NullInt64) MarshalJSON

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

this function is used when JSON tries to marshal this struct. Without it it will be marshalled into a JSON object with fields Time and Valid. This is far more elegant.

func (*NullInt64) Scan

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

Scan implements the Scanner interface.

func (*NullInt64) UnmarshalJSON

func (nt *NullInt64) UnmarshalJSON(b []byte) error

func (NullInt64) Value

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

Value implements the driver Valuer interface.

type NullString

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

func (NullString) MarshalJSON

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

this function is used when JSON tries to marshal this struct. Without it it will be marshalled into a JSON object with fields Time and Valid. This is far more elegant.

func (*NullString) Scan

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

Scan implements the Scanner interface.

func (*NullString) UnmarshalJSON

func (nt *NullString) UnmarshalJSON(b []byte) error

func (NullString) Value

func (nt 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
}

func (NullTime) GetHTMLDateTime

func (nt NullTime) GetHTMLDateTime() string

func (NullTime) MarshalJSON

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

this function is used when JSON tries to marshal this struct. Without it it will be marshalled into a JSON object with fields Time and Valid. This is far more elegant.

func (*NullTime) Scan

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

Scan implements the Scanner interface. Can scan from both time.Time and NullTime interfaces

func (*NullTime) UnmarshalJSON

func (nt *NullTime) UnmarshalJSON(b []byte) error

func (NullTime) Value

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

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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