null

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Float

type Float struct {
	sql.NullFloat64
}

Float is a nullable float64. It does not consider zero values to be null. It will decode to null, not zero, if null.

func FloatFrom

func FloatFrom(f float64) Float

FloatFrom creates a new Float that will always be valid.

func FloatFromPtr

func FloatFromPtr(f *float64) Float

FloatFromPtr creates a new Float that be null if f is nil.

func FloatFromString

func FloatFromString(f string, nullString string) (Float, error)

FloatFromString creates a new Float from string f. If the string is equal to the value of nullString then the Float will be null. An empty string f will return an error.

func NewFloat

func NewFloat(f float64, valid bool) Float

NewFloat creates a new Float

func (Float) FullString

func (f Float) FullString() string

FullString returns float as string in full precision

func (Float) IsZero

func (f Float) IsZero() bool

IsZero returns true for invalid Floats, for future omitempty support (Go 1.4?) A non-null Float with a 0 value will not be considered zero.

func (Float) MarshalJSON

func (f Float) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It will encode null if this Float is null.

func (Float) MarshalText

func (f Float) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Float is null.

func (Float) String

func (f Float) String() string

MarshalText implements encoding.TextMarshaler. It will encode a blank string if this Float is null.

func (*Float) UnmarshalJSON

func (f *Float) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler. It supports number and null input. 0 will not be considered a null Float. It also supports unmarshaling a sql.NullFloat64.

func (*Float) UnmarshalText

func (f *Float) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It will unmarshal to a null Float if the input is a blank or not an integer. It will return an error if the input is not an integer, blank, or "null".

Jump to

Keyboard shortcuts

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