go get -u github.com/cihangir/nisqlPackage nisql provides nullable types for database operations with proper json marshalling and unmarshalling
type NullBool struct {
sql.NullBool
}NullBool is a type that can be null or a bool
func Bool(b bool) NullBoolBool creates a valid NullBool
func (n *NullBool) Get() *boolGet returns nil or underlying bool value
func (n *NullBool) MarshalJSON() ([]byte, error)MarshalJSON implements the json.Marshaler interface.
func (n *NullBool) UnmarshalJSON(b []byte) errorUnmarshalJSON implements the json.Unmarshaler interface.
type NullFloat64 struct {
sql.NullFloat64
}NullFloat64 is a type that can be null or a float64
func Float64(f float64) NullFloat64Float64 creates a valid NullFloat64
func (n *NullFloat64) Get() *float64Get returns nil or underlying float64 value
func (n *NullFloat64) MarshalJSON() ([]byte, error)MarshalJSON implements the json.Marshaler interface.
func (n *NullFloat64) UnmarshalJSON(b []byte) errorUnmarshalJSON implements the json.Unmarshaler interface.
type NullInt64 struct {
sql.NullInt64
}NullInt64 is a type that can be null or an int
func Int64(i int64) NullInt64Int64 creates a valid NullInt64
func (n *NullInt64) Get() *int64Get returns nil or underlying int64 value
func (n *NullInt64) MarshalJSON() ([]byte, error)MarshalJSON implements the json.Marshaler interface.
func (n *NullInt64) UnmarshalJSON(b []byte) errorUnmarshalJSON implements the json.Unmarshaler interface.
type NullString struct {
sql.NullString
}NullString is a type that can be null or a string
func String(s string) NullStringString creates a valid NullString
func (n *NullString) Get() *stringGet returns nil or underlying string value
func (n *NullString) MarshalJSON() ([]byte, error)MarshalJSON implements the json.Marshaler interface.
func (n *NullString) UnmarshalJSON(b []byte) errorUnmarshalJSON implements the json.Unmarshaler interface.
type NullTime struct {
pq.NullTime
}NullTime is a type that can be null or a time.Time
func Time(t time.Time) NullTimeTime creates a valid NullTime
func (n *NullTime) Get() *time.TimeGet returns nil or underlying time.Time value
func (n *NullTime) MarshalJSON() ([]byte, error)MarshalJSON implements the json.Marshaler interface.
func (n *NullTime) UnmarshalJSON(b []byte) errorUnmarshalJSON implements the json.Unmarshaler interface.