Documentation
¶
Index ¶
- Constants
- Variables
- func Abs[I ~int | ~int8 | ~int16 | ~int32 | ~int64](i I) I
- func AllMapValueSlices[K comparable, T comparable](m map[K][]T, needDedup ...bool) []T
- func BatchCall[T any](op func([]T) bool, batchSize int, ts ...T)
- func CopySlice[T any](src []T) []T
- func GenerateQRCode(text, output string, options QRCodeOptions) error
- func GenerateQRCodeToWriter(text string, output io.Writer, options QRCodeOptions) error
- func Hash256(hasher hash.Hash, in ...[]byte) []byte
- func HostIP(hostOrIp string) (net.IP, error)
- 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 IsNil(v any) bool
- func JsonPrettyString(m any) (string, error)
- func JsonString(m any) (string, error)
- func LocalFirstIP(fn strategy.Func) (net.IP, error)
- func LocalMachineIfsIP2MAC(fn strategy.Func) (map[IPString]net.HardwareAddr, error)
- func MustJsonPrettyString(m any) string
- func MustJsonString(m any) string
- func NewIDValuer(ids ...int64) []driver.Valuer
- func OpenWriteFile(fullFilePathName string) (*os.File, error)
- func RandomBytes(length int) []byte
- func RemoveFile(fullFilePathName string) error
- 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 Date
- type Exister
- type F
- type ID
- type IPString
- 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]) KeySeq(filters ...func(k K, v V) bool) iter.Seq[K]
- 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]) RangeSubMap(batchSize int, ranger func(m KMap[K, V]) bool)
- 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]) In(e Exister[K]) KS[K]
- 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]) NotIn(e Exister[K]) KS[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]) Adds(it iter.Seq[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]) In(input iter.Seq[K]) iter.Seq[K]
- func (km KSet[K]) IsExist(k K) bool
- func (km KSet[K]) Keys() iter.Seq[K]
- func (km KSet[K]) RangeSubSet(batchSize int, ranger func(s KSet[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 List
- func (l *List[T]) All() iter.Seq[T]
- func (l *List[T]) Back() *ListElement[T]
- func (l *List[T]) Front() *ListElement[T]
- func (l *List[T]) Init() *List[T]
- func (l *List[T]) InsertAfter(v T, mark *ListElement[T]) *ListElement[T]
- func (l *List[T]) InsertBefore(v T, mark *ListElement[T]) *ListElement[T]
- func (l *List[T]) Len() int
- func (l *List[T]) MoveAfter(e, mark *ListElement[T])
- func (l *List[T]) MoveBefore(e, mark *ListElement[T])
- func (l *List[T]) MoveToBack(e *ListElement[T])
- func (l *List[T]) MoveToFront(e *ListElement[T])
- func (l *List[T]) PushBack(v T) *ListElement[T]
- func (l *List[T]) PushBackList(other *List[T])
- func (l *List[T]) PushFront(v T) *ListElement[T]
- func (l *List[T]) PushFrontList(other *List[T])
- func (l *List[T]) Remove(e *ListElement[T]) T
- type ListElement
- 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 OrderMap
- type QRCodeOptions
- type QRCodeRecoveryLevel
- 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) Float64() (float64, error)
- 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) SafeSlice(maxByteLen int) string
- 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) DedupIn(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 StrategyFunc
- type Time
- func NewDate(year int, month time.Month, day, hour, min, sec int) Time
- func NewFullDate(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) Time
- func NewTime(t time.Time) Time
- func NewUnixTime(ts int64) Time
- func Now() Time
- func ParseTime(layout, value string) (Time, error)
- func ZeroTime() Time
- func (t Time) AddDate(year, month, day int) 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) Day() int
- 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) Month() time.Month
- 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) Sub(o Time) time.Duration
- func (t Time) Time() time.Time
- func (t Time) ToDate() Date
- func (t Time) ToNullTime() NullTime
- 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)
- func (t Time) Year() int
- type Timestamp
- type Version
Constants ¶
const ( TimeTruncater = time.Millisecond DefaultTimeFormat = "2006-01-02 15:04:05 MST" TimeFormatWithMS = "2006-01-02 15:04:05.000 MST" DefaultParseLayout = time.DateTime DateTruncater = 24 * time.Hour DefaultDateFormat = time.DateOnly )
const (
// QRCodeDefaultLogoCover is the default logo cover ratio when logo is enabled.
QRCodeDefaultLogoCover = 0.20
)
Variables ¶
var ( ErrNilSource = errors.New("tools: nil source value") ErrNilValue = errors.New("tools: nil value") )
var ( ErrMissingText = errors.New("tools/qr: text is missing") ErrOutputPathEmpty = errors.New("tools/qr: output path cannot be empty") ErrOutputWriterNil = errors.New("tools/qr: output writer cannot be nil") ErrLogoSourceConflict = errors.New("tools/qr: logo source conflict") ErrLogoCoverNeedsLogo = errors.New("tools/qr: logo-cover requires logo") )
var ( // ByteSliceType is the reflect.Type for []byte. ByteSliceType = reflect.TypeOf([]byte{}) // StringType is the reflect.Type for string. StringType = reflect.TypeOf("") // StringSliceType is the reflect.Type for []string. StringSliceType = reflect.TypeOf([]string{}) // Int64Type is the reflect.Type for int64. Int64Type = reflect.TypeOf(int64(0)) // Int64SliceType is the reflect.Type for []int64. Int64SliceType = reflect.TypeOf([]int64{}) )
Functions ¶
func AllMapValueSlices ¶ added in v0.1.3
func AllMapValueSlices[K comparable, T comparable](m map[K][]T, needDedup ...bool) []T
func GenerateQRCode ¶ added in v0.2.0
func GenerateQRCode(text, output string, options QRCodeOptions) error
GenerateQRCode generates a QR image file with explicit text and options.
func GenerateQRCodeToWriter ¶ added in v0.2.0
func GenerateQRCodeToWriter(text string, output io.Writer, options QRCodeOptions) error
GenerateQRCodeToWriter generates a QR code PNG to writer with explicit text and options.
func HostIP ¶ added in v0.3.0
HostIP parses an input string (Host/IP/CIDR/Host:Port) into a valid net.IP object.
Supported Formats:
- Plain IP: "192.168.1.1", "fe80::1"
- Address with Port: "192.168.1.1:8080", "example.com:443"
- CIDR Notation: "192.168.1.100/24" (Extracts host IP "192.168.1.100", not network address ".0")
- Domain Names: "localhost", "example.com" (Triggers DNS lookup, prioritizes IPv4)
Parameters:
- hostOrIp: The string to be parsed.
Returns:
- net.IP: Resolved standard IP object.
- error: Returned if format parsing or DNS lookup fails.
func IndirectType ¶ added in v0.1.1
IndirectType dereferences typ until it reaches a non-pointer type. If typ is not a pointer, it is returned unchanged.
func IndirectValue ¶ added in v0.1.1
IndirectValue dereferences val until it reaches a non-pointer value. If val is not a pointer, it is returned unchanged.
func IsByteSlice ¶ added in v0.1.0
IsByteSlice reports whether the given reflect.Type represents a byte slice ([]byte).
func IsDefaultZero ¶ added in v0.1.0
IsDefaultZero reports whether t is the zero value of its type. An invalid reflect.Value is also considered zero.
func IsNil ¶ added in v0.2.2
IsNil reports whether v is nil. It handles both untyped nil and typed nil values of kinds Chan, Func, Interface, Map, Ptr, and Slice. An invalid reflect.Value is also considered nil.
func JsonPrettyString ¶ added in v0.0.5
func JsonString ¶
func LocalFirstIP ¶ added in v0.3.0
LocalFirstIP scans local network interfaces sequentially and returns the first IP matching the strategy.
Parameters:
- fn: Filter strategy callback. Accepts Interface and IP, returns bool. If fn is nil, no filtering is applied.
Returns:
- net.IP: The first matching IP address.
- error: Returned when reading interfaces fails or no matching IP is found.
func LocalMachineIfsIP2MAC ¶ added in v0.3.0
LocalMachineIfsIP2MAC scans all local network interfaces and extracts a map of IP addresses to MAC addresses matching the given strategy function.
Parameters:
- fn: Filter strategy callback. Accepts Interface and IP, returns bool. If fn is nil, no filtering is applied.
Returns:
- map[IPString]net.HardwareAddr: Map where key is normalized IP string and value is deep-copied HardwareAddr.
- error: Returned when reading system network interfaces fails.
func MustJsonPrettyString ¶ added in v0.0.5
func MustJsonString ¶ added in v0.0.5
func NewIDValuer ¶ added in v0.1.1
func RandomBytes ¶ added in v0.1.2
func RemoveFile ¶ added in v0.1.2
func SetByteSliceValue ¶ added in v0.1.0
SetByteSliceValue sets the reflect.Value val (which must represent a []byte) to the contents of bs. If val's capacity is insufficient, it allocates a new slice (val must be settable in that case). Returns an error if val cannot be set.
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 Date ¶ added in v0.1.2
func (Date) MarshalJSON ¶ added in v0.1.2
func (*Date) UnmarshalJSON ¶ added in v0.1.2
type Exister ¶ added in v0.1.2
type Exister[K comparable] interface { IsExist(k K) bool }
type IPString ¶ added in v0.3.0
type IPString string
IPString is a custom type for using IP addresses as map keys reliably.
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
func (KMap[K, V]) RangeSubMap ¶ added in v0.1.2
type KSet ¶
type KSet[K comparable] map[K]struct{}
func NewKSet ¶ added in v0.1.2
func NewKSet[K comparable](ks ...K) KSet[K]
func (KSet[K]) ExsitingList ¶ added in v0.0.5
func (km KSet[K]) ExsitingList(ks ...K) []K
func (KSet[K]) RangeSubSet ¶ added in v0.1.2
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 List ¶ added in v0.1.2
type List[T any] struct { // contains filtered or unexported fields }
List represents a doubly linked list. The zero value for List is an empty list ready to use.
func (*List[T]) Back ¶ added in v0.1.2
func (l *List[T]) Back() *ListElement[T]
Back returns the last element of list l or nil if the list is empty.
func (*List[T]) Front ¶ added in v0.1.2
func (l *List[T]) Front() *ListElement[T]
Front returns the first element of list l or nil if the list is empty.
func (*List[T]) Init ¶ added in v0.1.2
func (l *List[T]) Init() *List[T]
Init initializes or clears list l.
func (*List[T]) InsertAfter ¶ added in v0.1.2
func (l *List[T]) InsertAfter(v T, mark *ListElement[T]) *ListElement[T]
InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
func (*List[T]) InsertBefore ¶ added in v0.1.2
func (l *List[T]) InsertBefore(v T, mark *ListElement[T]) *ListElement[T]
InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
func (*List[T]) Len ¶ added in v0.1.2
func (l *List[T]) Len() int
Len returns the number of elements of list l. The complexity is O(1).
func (*List[T]) MoveAfter ¶ added in v0.1.2
func (l *List[T]) MoveAfter(e, mark *ListElement[T])
MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
func (*List[T]) MoveBefore ¶ added in v0.1.2
func (l *List[T]) MoveBefore(e, mark *ListElement[T])
MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
func (*List[T]) MoveToBack ¶ added in v0.1.2
func (l *List[T]) MoveToBack(e *ListElement[T])
MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*List[T]) MoveToFront ¶ added in v0.1.2
func (l *List[T]) MoveToFront(e *ListElement[T])
MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*List[T]) PushBack ¶ added in v0.1.2
func (l *List[T]) PushBack(v T) *ListElement[T]
PushBack inserts a new element e with value v at the back of list l and returns e.
func (*List[T]) PushBackList ¶ added in v0.1.2
func (l *List[T]) PushBackList(other *List[T])
PushBackList inserts a copy of another list at the back of list l. The lists l and other may be the same. They must not be nil.
func (*List[T]) PushFront ¶ added in v0.1.2
func (l *List[T]) PushFront(v T) *ListElement[T]
PushFront inserts a new element e with value v at the front of list l and returns e.
func (*List[T]) PushFrontList ¶ added in v0.1.2
func (l *List[T]) PushFrontList(other *List[T])
PushFrontList inserts a copy of another list at the front of list l. The lists l and other may be the same. They must not be nil.
func (*List[T]) Remove ¶ added in v0.1.2
func (l *List[T]) Remove(e *ListElement[T]) T
Remove removes e from l if e is an element of list l. It returns the element value e.value. The element must not be nil.
type ListElement ¶ added in v0.1.2
type ListElement[T any] struct { // The value stored with this element. Value T // contains filtered or unexported fields }
ListElement is an element of a linked list.
func (*ListElement[T]) Next ¶ added in v0.1.2
func (e *ListElement[T]) Next() *ListElement[T]
func (*ListElement[T]) Prev ¶ added in v0.1.2
func (e *ListElement[T]) Prev() *ListElement[T]
Prev returns the previous list element or nil.
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 NewNullInt32 ¶ added in v0.1.2
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 NewNullInt64 ¶ added in v0.1.2
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 EmptyNullString ¶ added in v0.1.2
func EmptyNullString(s string) NullString
func NewNullString ¶ added in v0.1.2
func NewNullString(s string, valid bool) NullString
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 ParseNullTime ¶ added in v0.1.2
func (NullTime) MarshalJSON ¶ added in v0.1.1
func (*NullTime) UnmarshalJSON ¶ added in v0.1.1
type OrderMap ¶ added in v0.1.2
type OrderMap[K comparable, V any] struct { // contains filtered or unexported fields }
OrderMap 一个按插入顺序遍历的map,也可以通过给出的排序器顺序遍历。线程不安全。
func NewOrderMap ¶ added in v0.1.2
func NewOrderMap[K comparable, V any]() *OrderMap[K, V]
type QRCodeOptions ¶ added in v0.2.0
type QRCodeOptions struct {
Level QRCodeRecoveryLevel
// Version accepts 0..40. 0 means auto-select the minimum valid version.
Version int
// Size is the output PNG width/height in pixels.
Size int
// LogoCover is the requested logo area ratio over QR code area.
// When logo is present and LogoCover is 0, QRCodeDefaultLogoCover is used.
LogoCover float64
// DisableForceHighestWhenLogo disables the default behavior that upgrades
// recovery level to highest when logo is present.
DisableForceHighestWhenLogo bool
// LogoPath is an optional logo image file path.
LogoPath string
// LogoReader is an optional logo image reader.
// Set either LogoPath or LogoReader, not both.
LogoReader io.Reader
}
QRCodeOptions contains common QR generation options shared by file/writer APIs.
type QRCodeRecoveryLevel ¶ added in v0.2.0
type QRCodeRecoveryLevel int
QRCodeRecoveryLevel is the QR error correction level used by this package's public API.
const ( QRCodeRecoveryLow QRCodeRecoveryLevel = QRCodeRecoveryLevel(qrcode.Low) QRCodeRecoveryMedium QRCodeRecoveryLevel = QRCodeRecoveryLevel(qrcode.Medium) QRCodeRecoveryHigh QRCodeRecoveryLevel = QRCodeRecoveryLevel(qrcode.High) QRCodeRecoveryHighest QRCodeRecoveryLevel = QRCodeRecoveryLevel(qrcode.Highest) )
type S ¶ added in v0.1.0
type S string
S is a string type with a set of convenient transformation and parsing methods.
func (S) CSVLike ¶ added in v0.1.0
CSVLike wraps s with SQL LIKE wildcards for CSV column matching: "%,s,%".
func (S) CSVSplit ¶ added in v0.1.0
CSVSplit splits s by commas, including Chinese comma (,) and enumeration comma (、).
func (S) CamelToSnake ¶ added in v0.1.0
CamelToSnake converts CamelCase to snake_case. Consecutive uppercase letters each get their own underscore prefix.
func (S) FirstRune ¶ added in v0.1.0
FirstRune returns the first Unicode code point of s, or 0 if s is empty.
func (S) FirstRuneString ¶ added in v0.1.0
FirstRuneString returns the first Unicode code point of s as an S, or "" if s is empty.
func (S) ID ¶ added in v0.1.0
ID parses s into an ID by extracting consecutive digits. It returns an error if s contains any non-digit characters.
func (S) Includes ¶ added in v0.1.0
Includes reports whether s contains every non-empty string in ss.
func (S) MustID ¶ added in v0.1.0
MustID is like ID but returns 0 on parse error instead of an error.
func (S) RegexpSplit ¶ added in v0.1.0
RegexpSplit splits s by the regular expression expr. It returns an error if expr fails to compile.
func (S) Replace ¶ added in v0.1.0
Replace returns a new S with all non-overlapping instances of source replaced by target.
func (S) SafeSlice ¶ added in v0.2.2
SafeSlice truncates s to fit within maxByteLen bytes without splitting a multi-byte rune. It returns the longest prefix whose byte length does not exceed maxLen.
func (S) SplitLines ¶ added in v0.1.0
SplitLines splits s into lines, handling both LF and CRLF line endings.
func (S) ToLower ¶ added in v0.1.0
ToLower returns a new S with all Unicode letters mapped to their lower case.
type SS ¶
type SS []string
func (SS) Dedup ¶
Dedup applies transfer to each element, filters out invalid values, keeps the first occurrence order, and returns a new deduplicated slice.
func (SS) DedupIn ¶ added in v0.1.4
DedupIn applies transfer and deduplicates elements in place. It rewrites the prefix of ss with unique values in first occurrence order and returns the resulting subslice.
type StrategyFunc ¶ added in v0.3.0
StrategyFunc is a type alias for strategy.Func to maintain backwards compatibility and avoid circular dependencies between tools and strategy packages.
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) ToNullTime ¶ added in v0.1.2
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 Timestamp ¶ added in v0.2.2
type Timestamp int64
func (Timestamp) DiffMillis ¶ added in v0.2.2
func (Timestamp) DiffSeconds ¶ added in v0.2.2
func (Timestamp) ToMilliSecond ¶ added in v0.2.2
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版