notnull

package
v0.0.0-...-f3f6071 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SQLArrayLiteral

func SQLArrayLiteral(s []string) string

SQLArrayLiteral joins the passed strings as an SQL array literal A nil slice will produce NULL, pass an empty non nil slice to get the empty SQL array literal {}.

func SplitArray

func SplitArray(array string) ([]string, error)

SplitArray splits an SQL or JSON array into its top level elements. Array elements that are quoted strings will not be unquoted. Returns a non nil empty slice in case of an empty array ("{}" or "[]") or when passing "null" or "NULL" as array.

Types

type FloatArray

type FloatArray []float64

FloatArray implements the sql.Scanner and driver.Valuer interfaces for a slice of float64. The nil default value of the slice is returned as an empty (non null) array for SQL and JSON. Use nullable.FloatArray if the nil value should be treated as SQL and JSON null.

func (FloatArray) Contains

func (a FloatArray) Contains(value float64) bool

Contains reports if the passed value is present in a.

func (FloatArray) Len

func (a FloatArray) Len() int

Len is the number of elements in the collection. One of the methods to implement sort.Interface.

func (FloatArray) Less

func (a FloatArray) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. One of the methods to implement sort.Interface.

func (FloatArray) MarshalJSON

func (a FloatArray) MarshalJSON() ([]byte, error)

MarshalJSON returns a as the JSON encoding of a. MarshalJSON implements encoding/json.Marshaler.

func (*FloatArray) Scan

func (a *FloatArray) Scan(src any) error

Scan implements the sql.Scanner interface.

func (FloatArray) String

func (a FloatArray) String() string

String implements the fmt.Stringer interface.

func (FloatArray) Swap

func (a FloatArray) Swap(i, j int)

Swap swaps the elements with indexes i and j. One of the methods to implement sort.Interface.

func (FloatArray) Value

func (a FloatArray) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface

type IntArray

type IntArray []int64

IntArray implements the sql.Scanner and driver.Valuer interfaces for a slice of int64. The nil default value of the slice is returned as an empty (non null) array for SQL and JSON. Use nullable.IntArray if the nil value should be treated as SQL and JSON null.

func (IntArray) Contains

func (a IntArray) Contains(value int64) bool

Contains reports if the passed value is present in a.

func (IntArray) Len

func (a IntArray) Len() int

Len is the number of elements in the collection. One of the methods to implement sort.Interface.

func (IntArray) Less

func (a IntArray) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. One of the methods to implement sort.Interface.

func (IntArray) MarshalJSON

func (a IntArray) MarshalJSON() ([]byte, error)

MarshalJSON returns a as the JSON encoding of a. MarshalJSON implements encoding/json.Marshaler.

func (*IntArray) Scan

func (a *IntArray) Scan(src any) error

Scan implements the sql.Scanner interface.

func (IntArray) String

func (a IntArray) String() string

String implements the fmt.Stringer interface.

func (IntArray) Swap

func (a IntArray) Swap(i, j int)

Swap swaps the elements with indexes i and j. One of the methods to implement sort.Interface.

func (IntArray) Value

func (a IntArray) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface

type JSON

type JSON []byte

JSON is a []byte slice containing JSON text. JSON(nil) is interpreted as an empty json object: {} Implements the interfaces: json.Marshaler, json.Unmarshaler, driver.Value, sql.Scanner. Use nullable.JSON if the JSON(nil) value should be interpreted as JSON "null" and SQL "NULL".

func MarshalJSON

func MarshalJSON(source any) (JSON, error)

func (JSON) Clone

func (j JSON) Clone() JSON

Clone returns a copy of j

func (JSON) GoString

func (j JSON) GoString() string

func (JSON) IsEmpty

func (j JSON) IsEmpty() bool

IsEmpty returns true if j is nil, or an empty JSON value like "", "{}", or "[]"

func (*JSON) MarshalFrom

func (j *JSON) MarshalFrom(source any) error

MarshalFrom marshalles source as JSON and sets it at j when there was no error.

func (JSON) MarshalJSON

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON returns j as the JSON encoding of j. MarshalJSON implements encoding/json.Marshaler See the package function MarshalJSON to marshal a struct into JSON

func (JSON) PrettyPrint

func (j JSON) PrettyPrint(w io.Writer)

func (*JSON) Scan

func (j *JSON) Scan(src any) error

Scan stores the src in *j. No validation is done.

func (JSON) String

func (j JSON) String() string

String returns the JSON as string. String implements the fmt.Stringer interface.

func (*JSON) UnmarshalJSON

func (j *JSON) UnmarshalJSON(sourceJSON []byte) error

UnmarshalJSON sets *j to a copy of sourceJSON. UnarshalJSON implements encoding/json.Unmarshaler See method Unmarshal for unmarshalling into a struct.

func (JSON) UnmarshalTo

func (j JSON) UnmarshalTo(dest any) error

UnmarshalTo unmashalles the JSON of j to dest

func (JSON) Valid

func (j JSON) Valid() bool

Valid reports whether j is a valid JSON encoding.

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value returns j as a SQL value.

type NullBoolArray

type NullBoolArray []sql.NullBool

NullBoolArray implements the sql.Scanner and driver.Valuer interfaces for a slice of sql.NullBool. The nil default value of the slice is returned as an empty (non null) array for SQL and JSON. Use nullable.NullBoolArray if the nil value should be treated as SQL and JSON null.

func (NullBoolArray) Bools

func (a NullBoolArray) Bools() []bool

Bools returns all NullBoolArray elements as []bool with NULL elements set to false.

func (*NullBoolArray) Scan

func (a *NullBoolArray) Scan(src any) error

Scan implements the sql.Scanner interface

func (NullBoolArray) String

func (a NullBoolArray) String() string

String implements the fmt.Stringer interface.

func (NullBoolArray) Value

func (a NullBoolArray) Value() (driver.Value, error)

Value implements the database/sql/driver.Valuer interface

type StringArray

type StringArray []string

StringArray implements the sql.Scanner, driver.Valuer, and encoding/json.Marshaler interfaces for a slice of strings. The nil default value of the slice is returned as an empty (non null) array for SQL and JSON. Use nullable.StringArray if the nil value should be treated as SQL and JSON null.

func (StringArray) Contains

func (a StringArray) Contains(value string) bool

Contains reports if the passed value is present in a.

func (StringArray) Len

func (a StringArray) Len() int

Len is the number of elements in the collection. One of the methods to implement sort.Interface.

func (StringArray) Less

func (a StringArray) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j. One of the methods to implement sort.Interface.

func (StringArray) MarshalJSON

func (a StringArray) MarshalJSON() ([]byte, error)

MarshalJSON returns a as the JSON encoding of a. MarshalJSON implements encoding/json.Marshaler.

func (*StringArray) Scan

func (a *StringArray) Scan(src any) error

Scan implements the sql.Scanner interface.

func (StringArray) Swap

func (a StringArray) Swap(i, j int)

Swap swaps the elements with indexes i and j. One of the methods to implement sort.Interface.

func (StringArray) Value

func (a StringArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type TrimmedString

type TrimmedString string

TrimmedString is a string type where all marshaller and unmarshaller will trim whitespace first before returning or using a value. TrimmedString can hold an empty string.

func JoinTrimmedStrings

func JoinTrimmedStrings(separator string, strs ...TrimmedString) TrimmedString

JoinTrimmedStrings joins trimmed strings with the passed separator between them

func TrimmedStringFrom

func TrimmedStringFrom(str string) TrimmedString

TrimmedStringFrom trims the passed str and returns it as TrimmedString

func TrimmedStringf

func TrimmedStringf(format string, a ...any) TrimmedString

TrimmedStringf formats a string using fmt.Sprintf and returns it as TrimmedString.

func (TrimmedString) Contains

func (s TrimmedString) Contains(substr string) bool

Contains reports whether substr is within s.

func (TrimmedString) ContainsAny

func (s TrimmedString) ContainsAny(chars string) bool

ContainsAny reports whether any Unicode code points in chars are within s.

func (TrimmedString) ContainsRune

func (s TrimmedString) ContainsRune(r rune) bool

ContainsRune reports whether the Unicode code point r is within s.

func (TrimmedString) HasPrefix

func (s TrimmedString) HasPrefix(prefix string) bool

HasPrefix tests whether the TrimmedString begins with prefix.

func (TrimmedString) HasSuffix

func (s TrimmedString) HasSuffix(suffix string) bool

HasSuffix tests whether the TrimmedString ends with suffix.

func (TrimmedString) IsEmpty

func (s TrimmedString) IsEmpty() bool

IsEmpty indicates if the trimmed string is empty which is also the case when the underlying string consisting only of whitespace.

func (TrimmedString) MarshalJSON

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

MarshalJSON implements encoding/json.Marshaler

func (TrimmedString) MarshalText

func (s TrimmedString) MarshalText() ([]byte, error)

UnmarshalText implements the encoding.TextMarshaler interface

func (TrimmedString) MarshalXML

func (s TrimmedString) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (TrimmedString) ReplaceAll

func (s TrimmedString) ReplaceAll(old, new string) TrimmedString

ReplaceAll returns a copy of the TrimmedString with all non-overlapping instances of old replaced by new. If old is empty, it matches at the beginning of the string and after each UTF-8 sequence, yielding up to k+1 replacements for a k-rune string.

func (*TrimmedString) Scan

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

Scan implements the database/sql.Scanner interface

func (*TrimmedString) Set

func (s *TrimmedString) Set(str string)

Set the passed string as TrimmedString

func (TrimmedString) Split

func (s TrimmedString) Split(sep string) []TrimmedString

Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators.

If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.

If sep is empty, Split splits after each UTF-8 sequence. If both s and sep are empty, Split returns an empty slice.

It is equivalent to SplitN with a count of -1.

To split around the first instance of a separator, see Cut.

func (TrimmedString) String

func (s TrimmedString) String() string

String implements the fmt.Stringer interface by returning a trimmed string that might be empty if the underlying string consisting only of whitespace.

func (TrimmedString) ToLower

func (s TrimmedString) ToLower() TrimmedString

ToLower returns s with all Unicode letters mapped to their lower case.

func (TrimmedString) ToUpper

func (s TrimmedString) ToUpper() TrimmedString

ToUpper returns s with all Unicode letters mapped to their upper case.

func (TrimmedString) ToValidUTF8

func (s TrimmedString) ToValidUTF8(replacement string) TrimmedString

ToValidUTF8 returns a copy of the TrimmedString with each run of invalid UTF-8 byte sequences replaced by the replacement string, which may be empty.

func (TrimmedString) TrimPrefix

func (s TrimmedString) TrimPrefix(prefix string) TrimmedString

TrimPrefix returns s without the provided leading prefix string. If the TrimmedString doesn't start with prefix, s is returned unchanged.

func (TrimmedString) TrimSuffix

func (s TrimmedString) TrimSuffix(suffix string) TrimmedString

TrimSuffix returns s without the provided trailing suffix string. If the TrimmedString doesn't end with suffix, s is returned unchanged.

func (*TrimmedString) UnmarshalJSON

func (s *TrimmedString) UnmarshalJSON(j []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler

func (*TrimmedString) UnmarshalText

func (s *TrimmedString) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface

func (*TrimmedString) UnmarshalXML

func (s *TrimmedString) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (TrimmedString) Value

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

Value implements the driver database/sql/driver.Valuer interface

Jump to

Keyboard shortcuts

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