Documentation ¶
Index ¶
- func SQLArrayLiteral(s []string) string
- func SplitArray(array string) ([]string, error)
- type FloatArray
- func (a FloatArray) Contains(value float64) bool
- func (a FloatArray) Len() int
- func (a FloatArray) Less(i, j int) bool
- func (a FloatArray) MarshalJSON() ([]byte, error)
- func (a *FloatArray) Scan(src any) error
- func (a FloatArray) String() string
- func (a FloatArray) Swap(i, j int)
- func (a FloatArray) Value() (driver.Value, error)
- type IntArray
- func (a IntArray) Contains(value int64) bool
- func (a IntArray) Len() int
- func (a IntArray) Less(i, j int) bool
- func (a IntArray) MarshalJSON() ([]byte, error)
- func (a *IntArray) Scan(src any) error
- func (a IntArray) String() string
- func (a IntArray) Swap(i, j int)
- func (a IntArray) Value() (driver.Value, error)
- type JSON
- func (j JSON) Clone() JSON
- func (j JSON) GoString() string
- func (j JSON) IsEmpty() bool
- func (j *JSON) MarshalFrom(source any) error
- func (j JSON) MarshalJSON() ([]byte, error)
- func (j JSON) PrettyPrint(w io.Writer)
- func (j *JSON) Scan(src any) error
- func (j JSON) String() string
- func (j *JSON) UnmarshalJSON(sourceJSON []byte) error
- func (j JSON) UnmarshalTo(dest any) error
- func (j JSON) Valid() bool
- func (j JSON) Value() (driver.Value, error)
- type NullBoolArray
- type StringArray
- func (a StringArray) Contains(value string) bool
- func (a StringArray) Len() int
- func (a StringArray) Less(i, j int) bool
- func (a StringArray) MarshalJSON() ([]byte, error)
- func (a *StringArray) Scan(src any) error
- func (a StringArray) Swap(i, j int)
- func (a StringArray) Value() (driver.Value, error)
- type TrimmedString
- func (s TrimmedString) Contains(substr string) bool
- func (s TrimmedString) ContainsAny(chars string) bool
- func (s TrimmedString) ContainsRune(r rune) bool
- func (s TrimmedString) HasPrefix(prefix string) bool
- func (s TrimmedString) HasSuffix(suffix string) bool
- func (s TrimmedString) IsEmpty() bool
- func (s TrimmedString) MarshalJSON() ([]byte, error)
- func (s TrimmedString) MarshalText() ([]byte, error)
- func (s TrimmedString) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (s TrimmedString) ReplaceAll(old, new string) TrimmedString
- func (s *TrimmedString) Scan(value any) error
- func (s *TrimmedString) Set(str string)
- func (s TrimmedString) Split(sep string) []TrimmedString
- func (s TrimmedString) String() string
- func (s TrimmedString) ToLower() TrimmedString
- func (s TrimmedString) ToUpper() TrimmedString
- func (s TrimmedString) ToValidUTF8(replacement string) TrimmedString
- func (s TrimmedString) TrimPrefix(prefix string) TrimmedString
- func (s TrimmedString) TrimSuffix(suffix string) TrimmedString
- func (s *TrimmedString) UnmarshalJSON(j []byte) error
- func (s *TrimmedString) UnmarshalText(text []byte) error
- func (s *TrimmedString) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (s TrimmedString) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SQLArrayLiteral ¶
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 ¶
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.
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) Len ¶
Len is the number of elements in the collection. One of the methods to implement sort.Interface.
func (IntArray) Less ¶
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 ¶
MarshalJSON returns a as the JSON encoding of a. MarshalJSON implements encoding/json.Marshaler.
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 (JSON) IsEmpty ¶
IsEmpty returns true if j is nil, or an empty JSON value like "", "{}", or "[]"
func (*JSON) MarshalFrom ¶
MarshalFrom marshalles source as JSON and sets it at j when there was no error.
func (JSON) MarshalJSON ¶
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 (JSON) String ¶
String returns the JSON as string. String implements the fmt.Stringer interface.
func (*JSON) UnmarshalJSON ¶
UnmarshalJSON sets *j to a copy of sourceJSON. UnarshalJSON implements encoding/json.Unmarshaler See method Unmarshal for unmarshalling into a struct.
func (JSON) UnmarshalTo ¶
UnmarshalTo unmashalles the JSON of j to dest
type NullBoolArray ¶
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.
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.
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