Documentation
¶
Index ¶
- Constants
- Variables
- func Abs[I ~int | ~int8 | ~int16 | ~int32 | ~int64](i I) I
- func CopySlice[T any](src []T) []T
- func IF[T any](condition bool, trueValue T, falseValue T) T
- func IndirectType(typ reflect.Type) reflect.Type
- func IndirectValue(val reflect.Value) reflect.Value
- func IsByteSlice(typ reflect.Type) bool
- func IsDefaultZero[T any](t T) bool
- func JsonPrettyString(m any) (string, error)
- func JsonString(m any) (string, error)
- func MustJsonPrettyString(m any) string
- func MustJsonString(m any) string
- func NewIDValuer(ids ...int64) []driver.Valuer
- func SetByteSliceValue(val reflect.Value, bs []byte) error
- func SplitNetAddr(addr string) (host string, port int)
- func SsToTs[S, T any](transmitter func(S) T, ss ...S) []T
- func TsToSs[T, S any](transmitter func(T) (S, bool), ts ...T) []S
- func ValidAndCreateDir(pstr string, checkAndCreateIfAbsent bool) (string, error)
- func VariadicParam[T any](params []T, defaultValue ...T) T
- type B
- type Bs
- type F
- type ID
- type JSON
- func (j *JSON) Bytes() []byte
- func (j *JSON) Clone() JSON
- func (j *JSON) Equal(o *JSON) bool
- func (j JSON) Format(f fmt.State, c rune)
- func (j JSON) IsNull() bool
- func (j JSON) MarshalJSON() ([]byte, error)
- func (j *JSON) Scan(value interface{}) error
- func (j *JSON) String() string
- func (j *JSON) UnmarshalJSON(data []byte) error
- func (j JSON) Value() (driver.Value, error)
- type JSONArray
- type JSONBuilder
- type KKMap
- func (kkm KKMap[K1, K2, V]) Delete(k1 K1, k2 K2)
- func (kkm KKMap[K1, K2, V]) DeleteKey(k1 K1)
- func (kkm KKMap[K1, K2, V]) Get(k1 K1, k2 K2) (v V, exist bool)
- func (kkm KKMap[K1, K2, V]) IsExist(k1 K1, k2 K2) (exist bool)
- func (kkm KKMap[K1, K2, V]) IsExistKey(k1 K1) (exist bool)
- func (kkm KKMap[K1, K2, V]) Put(k1 K1, k2 K2, v V) KKMap[K1, K2, V]
- func (kkm KKMap[K1, K2, V]) PutKey(k1 K1, km2 map[K2]V) KKMap[K1, K2, V]
- func (kkm KKMap[K1, K2, V]) Range(handler func(k1 K1, k2 K2, v V) (goon bool))
- type KMap
- func (km KMap[K, V]) Delete(ks ...K)
- func (km KMap[K, V]) ExistingList(keys ...K) []V
- func (km KMap[K, V]) Get(k K) (v V, exist bool)
- func (km KMap[K, V]) IsExist(key K) bool
- func (km KMap[K, V]) Keys(filters ...func(k K, v V) bool) []K
- func (km KMap[K, V]) List(keys ...K) []V
- func (km KMap[K, V]) Map() map[K]V
- func (km KMap[K, V]) Merge(kmo KMap[K, V]) KMap[K, V]
- func (km KMap[K, V]) Put(key K, value V) KMap[K, V]
- func (km KMap[K, V]) Puts(it iter.Seq2[K, V]) KMap[K, V]
- func (km KMap[K, V]) SubMap(ks ...K) KMap[K, V]
- func (km KMap[K, V]) Values(filters ...func(k K, v V) bool) []V
- func (km KMap[K, V]) ValuesSeq(filters ...func(k K, v V) bool) iter.Seq[V]
- type KS
- func (ks KS[K]) All() iter.Seq[K]
- func (ks KS[K]) Append(k K) KS[K]
- func (ks KS[K]) Clone() KS[K]
- func (ks KS[K]) Contains(tgt K) bool
- func (ks KS[K]) Dedup(validators ...func(k K) bool) KS[K]
- func (ks KS[K]) DedupRange(one func(k K) error) error
- func (ks KS[K]) Equal(os KS[K]) bool
- func (ks KS[K]) IterateRemove(tgt K) KS[K]
- func (ks KS[K]) Map(validators ...func(k K) bool) KSet[K]
- func (ks KS[K]) Remove(tgts ...K) KS[K]
- func (ks KS[K]) Slice() []K
- func (ks KS[K]) Sub(offset, limit int) KS[K]
- type KSet
- func (km KSet[K]) Add(ks ...K) KSet[K]
- func (km KSet[K]) Append(ks ...K) KSet[K]
- func (km KSet[K]) AppendSet(s KSet[K]) KSet[K]
- func (km KSet[K]) Appends(it iter.Seq[K]) KSet[K]
- func (km KSet[K]) CAS(k K) (set KSet[K], changed bool)
- func (km KSet[K]) Clone() KSet[K]
- func (km KSet[K]) Delete(ks ...K) KSet[K]
- func (km KSet[K]) Equal(o KSet[K]) bool
- func (km KSet[K]) ExsitingList(ks ...K) []K
- func (km KSet[K]) IsExist(k K) bool
- func (km KSet[K]) Slice(emptyNil ...bool) []K
- type KV
- func (KV[K, V]) KeyNotInMap(m map[K]V, ks ...K) []K
- func (KV[K, V]) List(keys []K, valuesMap map[K]V) []V
- func (KV[K, V]) MapKeys(m map[K]V) []K
- func (KV[K, V]) MapValues(m map[K]V) []V
- func (KV[K, V]) OneOfMap(k K, mapper func([]K) (map[K]V, error)) (v V, err error)
- func (KV[K, V]) PutToMap(m map[K]V, k K, v V) map[K]V
- func (KV[K, V]) RangeByK(ks []K, m map[K]V, dowork func(k K, v V) error) error
- type NotNullJSON
- func (n *NotNullJSON) Bytes() []byte
- func (n *NotNullJSON) Clone() NotNullJSON
- func (n *NotNullJSON) Equal(o *NotNullJSON) bool
- func (n NotNullJSON) IsNull() bool
- func (n NotNullJSON) MarshalJSON() ([]byte, error)
- func (n *NotNullJSON) Scan(value interface{}) error
- func (n *NotNullJSON) String() string
- func (n NotNullJSON) ToJSON() JSON
- func (n *NotNullJSON) UnmarshalJSON(data []byte) error
- func (n NotNullJSON) Value() (driver.Value, error)
- type NullInt32
- func (i NullInt32) Int() int32
- func (i NullInt32) IsAvailable() bool
- func (i NullInt32) IsNull() bool
- func (i NullInt32) MarshalJSON() ([]byte, error)
- func (i *NullInt32) Scan(value any) error
- func (i NullInt32) String() string
- func (i *NullInt32) UnmarshalJSON(input []byte) error
- func (i NullInt32) Value() (driver.Value, error)
- type NullInt64
- func (i *NullInt64) Clear()
- func (i NullInt64) Int() int64
- func (i NullInt64) IsAvailable() bool
- func (i NullInt64) IsNull() bool
- func (i NullInt64) MarshalJSON() ([]byte, error)
- func (i *NullInt64) Scan(value any) error
- func (i *NullInt64) SetValue(val int64)
- func (i NullInt64) String() string
- func (i *NullInt64) UnmarshalJSON(input []byte) error
- func (i NullInt64) Value() (driver.Value, error)
- type NullString
- type NullTime
- func (n NullTime) Compare(ti time.Time) int
- func (n NullTime) Equal(o NullTime) bool
- func (n NullTime) Format(layout string) string
- func (n NullTime) IsNull() bool
- func (n NullTime) MarshalJSON() ([]byte, error)
- func (n NullTime) Obj() time.Time
- func (n *NullTime) Scan(value any) error
- func (n NullTime) String() string
- func (n NullTime) ToTime() Time
- func (n *NullTime) UnmarshalJSON(data []byte) error
- func (n NullTime) Value() (driver.Value, error)
- type S
- func (s S) Bytes() []byte
- func (s S) CSVLike() string
- func (s S) CSVSplit() []string
- func (s S) CamelToSnake() S
- func (s S) FirstByte() byte
- func (s S) FirstRune() rune
- func (s S) FirstRuneString() S
- func (s S) Formalize() S
- func (s S) ID() (ID, error)
- func (s S) Includes(ss ...string) bool
- func (s S) Int64() (int64, error)
- func (s S) IsValid() bool
- func (s S) JSON() (JSON, error)
- func (s S) Like() string
- func (s S) MustID() ID
- func (s S) RegexpSplit(expr string) ([]string, error)
- func (s S) Replace(source, target string) S
- func (s S) SplitBy(sep string) []string
- func (s S) SplitLines() (SS, error)
- func (s S) String() string
- func (s S) ToLower() S
- func (s S) ToUpper() S
- func (s S) Trim() S
- type SS
- func (ss SS) Append(s ...string) SS
- func (ss SS) Clone() SS
- func (ss SS) Dedup(transfers ...func(input string) (string, bool)) SS
- func (ss SS) Has(s string) bool
- func (ss SS) Join(sep string) string
- func (ss SS) Map() KSet[string]
- func (ss SS) Matchs(str string) bool
- func (ss SS) Remove(strs ...string) SS
- func (ss SS) Slice() []string
- func (ss SS) Sort() SS
- type Time
- func (t Time) After(d time.Duration) Time
- func (t Time) Before(d time.Duration) Time
- func (t Time) Compare(o Time) int
- func (t Time) CurrentHour() Time
- func (t Time) CurrentRound(interval time.Duration) Time
- func (t Time) DetailString() string
- func (t Time) Equal(o Time) bool
- func (t Time) FromUnix(seconds int64) Time
- func (t Time) HourAfter(d time.Duration) Time
- func (t Time) IsZero() bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) NNUnixMilli() int64
- func (t Time) NextHour() Time
- func (t Time) NextRound(interval time.Duration) Time
- func (t *Time) Scan(value any) error
- func (t Time) String() string
- func (t Time) Time() time.Time
- func (t Time) UTCString() string
- func (t Time) Unix() int64
- func (t Time) UnixMilli() int64
- func (t Time) UnixMilliString() string
- func (t Time) UnixString() string
- func (t *Time) UnmarshalJSON(data []byte) error
- func (t Time) Value() (driver.Value, error)
- type Version
Constants ¶
const ( TimeTruncater = time.Millisecond DefaultTimeFormat = "2006-01-02 15:04:05 MST" TimeFormatWithMS = "2006-01-02 15:04:05.000 MST" )
Variables ¶
var ( ErrNilSource = errors.New("tools: nil source value") ErrNilValue = errors.New("tools: nil value") )
Functions ¶
func IsByteSlice ¶ added in v0.1.0
func IsDefaultZero ¶ added in v0.1.0
func JsonPrettyString ¶ added in v0.0.5
func JsonString ¶
func MustJsonPrettyString ¶ added in v0.0.5
func MustJsonString ¶ added in v0.0.5
func NewIDValuer ¶ added in v0.1.1
func SplitNetAddr ¶ added in v0.1.1
SplitNetAddr like host:port to host and port if there's no valid host exists, return "" if there's no valid port exists, return -1
func ValidAndCreateDir ¶ added in v0.1.1
ValidAndCreateDir 将传入的绝对路径pstr当作文件目录,确认其存在,如果不存在则创建。并返回包含最后的路径分隔符的绝对路径字符串
func VariadicParam ¶ added in v0.1.1
func VariadicParam[T any](params []T, defaultValue ...T) T
Types ¶
type JSONArray ¶ added in v0.0.6
type JSONArray[T comparable] []T
func NewJSONArray ¶ added in v0.0.6
func NewJSONArray[T comparable](data JSON) (ja JSONArray[T], err error)
func (JSONArray[T]) MarshalJSON ¶ added in v0.0.6
func (JSONArray[T]) ToNotNullJSON ¶ added in v0.0.6
func (ja JSONArray[T]) ToNotNullJSON() (NotNullJSON, error)
type JSONBuilder ¶
type JSONBuilder struct{}
func (JSONBuilder) FromString ¶
func (b JSONBuilder) FromString(jsonStr string) (JSON, error)
func (JSONBuilder) NoErrObj ¶
func (b JSONBuilder) NoErrObj(obj any) JSON
func (JSONBuilder) NoErrString ¶
func (b JSONBuilder) NoErrString(jsonStr string) JSON
type KKMap ¶
type KKMap[K1 comparable, K2 comparable, V any] map[K1]map[K2]V
func (KKMap[K1, K2, V]) IsExistKey ¶ added in v0.0.5
type KMap ¶
type KMap[K comparable, V any] map[K]V
func (KMap[K, V]) ExistingList ¶ added in v0.0.5
func (km KMap[K, V]) ExistingList(keys ...K) []V
type KSet ¶
type KSet[K comparable] map[K]struct{}
func (KSet[K]) ExsitingList ¶ added in v0.0.5
func (km KSet[K]) ExsitingList(ks ...K) []K
type KV ¶
type KV[K comparable, V any] struct{}
func (KV[K, V]) KeyNotInMap ¶
func (KV[K, V]) KeyNotInMap(m map[K]V, ks ...K) []K
type NotNullJSON ¶
type NotNullJSON JSON
func (*NotNullJSON) Bytes ¶
func (n *NotNullJSON) Bytes() []byte
func (*NotNullJSON) Clone ¶
func (n *NotNullJSON) Clone() NotNullJSON
func (*NotNullJSON) Equal ¶
func (n *NotNullJSON) Equal(o *NotNullJSON) bool
func (NotNullJSON) IsNull ¶
func (n NotNullJSON) IsNull() bool
func (NotNullJSON) MarshalJSON ¶
func (n NotNullJSON) MarshalJSON() ([]byte, error)
func (*NotNullJSON) Scan ¶
func (n *NotNullJSON) Scan(value interface{}) error
func (*NotNullJSON) String ¶
func (n *NotNullJSON) String() string
func (NotNullJSON) ToJSON ¶ added in v0.0.5
func (n NotNullJSON) ToJSON() JSON
func (*NotNullJSON) UnmarshalJSON ¶
func (n *NotNullJSON) UnmarshalJSON(data []byte) error
type NullInt32 ¶ added in v0.1.1
func LE0NullInt32 ¶ added in v0.1.1
LE0NullInt32 Less or Equal 0 is Null, or not Null
func (NullInt32) IsAvailable ¶ added in v0.1.1
func (NullInt32) MarshalJSON ¶ added in v0.1.1
func (*NullInt32) UnmarshalJSON ¶ added in v0.1.1
type NullInt64 ¶ added in v0.1.1
func LE0NullInt64 ¶ added in v0.1.1
LE0NullInt64 Less or Equal to 0 is Null, or not Null
func (NullInt64) IsAvailable ¶ added in v0.1.1
func (NullInt64) MarshalJSON ¶ added in v0.1.1
func (*NullInt64) UnmarshalJSON ¶ added in v0.1.1
type NullString ¶ added in v0.1.1
func (NullString) IsNull ¶ added in v0.1.1
func (n NullString) IsNull() bool
func (NullString) MarshalJSON ¶ added in v0.1.1
func (n NullString) MarshalJSON() ([]byte, error)
func (*NullString) Scan ¶ added in v0.1.1
func (n *NullString) Scan(value any) error
func (NullString) String ¶ added in v0.1.1
func (n NullString) String() string
func (*NullString) UnmarshalJSON ¶ added in v0.1.1
func (n *NullString) UnmarshalJSON(data []byte) error
type NullTime ¶ added in v0.1.1
func NewNullTime ¶ added in v0.1.1
func NewNullUnixTime ¶ added in v0.1.1
func (NullTime) MarshalJSON ¶ added in v0.1.1
func (*NullTime) UnmarshalJSON ¶ added in v0.1.1
type S ¶ added in v0.1.0
type S string
func (S) CamelToSnake ¶ added in v0.1.0
func (S) FirstRuneString ¶ added in v0.1.0
func (S) SplitLines ¶ added in v0.1.0
type SS ¶
type SS []string
type Time ¶ added in v0.1.0
Time mysql timestamp precision to seconds using Now(), NewTime(), NewUnixTime() or ZeroTime() to create Time which is without monotonic clock reading (by truncating millisecond)
func NewFullDate ¶ added in v0.1.0
func NewUnixTime ¶ added in v0.1.0
func ZeroTime ¶ added in v0.1.0
func ZeroTime() Time
ZeroTime according to time.Time document, which is Jan 1 year 1.
func (Time) CurrentHour ¶ added in v0.1.0
func (Time) DetailString ¶ added in v0.1.0
func (Time) MarshalJSON ¶ added in v0.1.0
func (Time) NNUnixMilli ¶ added in v0.1.0
NNUnixMilli not negetive unix milli
func (Time) UnixMilliString ¶ added in v0.1.0
func (Time) UnixString ¶ added in v0.1.0
func (*Time) UnmarshalJSON ¶ added in v0.1.0
type Version ¶ added in v0.1.1
type Version int64
Version 使用64位有符号整数,分为3部分,major.minor.patch,每部分使用6位数,最大支持999,999 patch 使用十进制最低6位数 minor 使用十进制第12位到第7位数 major 使用十进制第18位到第13位数 符号为+时,为正式版,为-时,为alpha版,0.0.0没有alpha版