typex

package module
v1.25.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: Apache-2.0 Imports: 4 Imported by: 19

README

typex

类型封装

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	// contains filtered or unexported fields
}

func NewBool

func NewBool(v ...bool) *Bool

func (*Bool) Bool

func (x *Bool) Bool(def ...bool) bool

func (*Bool) Float64

func (x *Bool) Float64(def ...float64) float64

func (*Bool) Int

func (x *Bool) Int(def ...int) int

func (*Bool) Int64

func (x *Bool) Int64(def ...int64) int64

func (*Bool) MarshalJSON

func (x *Bool) MarshalJSON() ([]byte, error)

func (*Bool) String

func (x *Bool) String(def ...string) string

func (*Bool) UnmarshalJSON

func (x *Bool) UnmarshalJSON(bytes []byte) error

func (*Bool) Valid

func (x *Bool) Valid() bool

func (*Bool) Value

func (x *Bool) Value(def ...bool) bool

type Date

type Date struct {
	// contains filtered or unexported fields
}

func NewDate

func NewDate(v ...time.Time) *Date

func (*Date) MarshalJSON

func (x *Date) MarshalJSON() ([]byte, error)

func (*Date) UnmarshalJSON

func (x *Date) UnmarshalJSON(bytes []byte) error

func (*Date) Valid

func (x *Date) Valid() bool

func (*Date) Value

func (x *Date) Value(def ...time.Time) time.Time

type Enum

type Enum[KT comparable, VT any] struct {
	// contains filtered or unexported fields
}

func NewEnum

func NewEnum[KT comparable, VT any]() *Enum[KT, VT]

NewEnum key为comparable类型,value为任意类型

func NewIntEnum

func NewIntEnum[T any]() *Enum[int, T]

NewIntEnum key为int类型,value为任意类型

func NewStringEnum

func NewStringEnum[T any]() *Enum[string, T]

NewStringEnum key为string类型,value为任意类型

func (*Enum[KT, VT]) Add

func (e *Enum[KT, VT]) Add(k KT, v VT) *Enum[KT, VT]

func (*Enum[KT, VT]) Clear

func (e *Enum[KT, VT]) Clear()

func (*Enum[KT, VT]) Exist

func (e *Enum[KT, VT]) Exist(k KT) bool

func (*Enum[KT, VT]) Get

func (e *Enum[KT, VT]) Get(k KT) VT

func (*Enum[KT, VT]) Keys

func (e *Enum[KT, VT]) Keys() []KT

func (*Enum[KT, VT]) Len

func (e *Enum[KT, VT]) Len() int

func (*Enum[KT, VT]) Remove

func (e *Enum[KT, VT]) Remove(k KT)

func (*Enum[KT, VT]) Values

func (e *Enum[KT, VT]) Values() []VT

type Float64

type Float64 struct {
	// contains filtered or unexported fields
}

func NewFloat64

func NewFloat64(t ...float64) *Float64

func (*Float64) Bool

func (x *Float64) Bool(def ...bool) bool

func (*Float64) Float64

func (x *Float64) Float64(def ...float64) float64

func (*Float64) Int

func (x *Float64) Int(def ...int) int

func (*Float64) Int64

func (x *Float64) Int64(def ...int64) int64

func (*Float64) MarshalJSON

func (x *Float64) MarshalJSON() ([]byte, error)

func (*Float64) String

func (x *Float64) String(def ...string) string

func (*Float64) UnmarshalJSON

func (x *Float64) UnmarshalJSON(bytes []byte) error

func (*Float64) Valid

func (x *Float64) Valid() bool

func (*Float64) Value

func (x *Float64) Value(def ...float64) float64

type Int

type Int struct {
	// contains filtered or unexported fields
}

func NewInt

func NewInt(v ...int) *Int

func (*Int) Bool

func (x *Int) Bool(def ...bool) bool

func (*Int) Float64

func (x *Int) Float64(def ...float64) float64

func (*Int) Int

func (x *Int) Int(def ...int) int

func (*Int) Int64

func (x *Int) Int64(def ...int64) int64

func (*Int) MarshalJSON

func (x *Int) MarshalJSON() ([]byte, error)

func (*Int) String

func (x *Int) String(def ...string) string

func (*Int) UnmarshalJSON

func (x *Int) UnmarshalJSON(bytes []byte) error

func (*Int) Valid

func (x *Int) Valid() bool

func (*Int) Value

func (x *Int) Value(def ...int) int

type Int64

type Int64 struct {
	// contains filtered or unexported fields
}

func NewInt64

func NewInt64(v ...int64) *Int64

func (*Int64) Bool

func (x *Int64) Bool(def ...bool) bool

func (*Int64) Float64

func (x *Int64) Float64(def ...float64) float64

func (*Int64) Int

func (x *Int64) Int(def ...int) int

func (*Int64) Int64

func (x *Int64) Int64(def ...int64) int64

func (*Int64) MarshalJSON

func (x *Int64) MarshalJSON() ([]byte, error)

func (*Int64) String

func (x *Int64) String(def ...string) string

func (*Int64) UnmarshalJSON

func (x *Int64) UnmarshalJSON(bytes []byte) error

func (*Int64) Valid

func (x *Int64) Valid() bool

func (*Int64) Value

func (x *Int64) Value(def ...int64) int64

type Node

type Node interface {
	ID() string
	PID() string
}

type String

type String struct {
	// contains filtered or unexported fields
}

func NewString

func NewString(v ...string) *String

func (*String) Bool

func (x *String) Bool(def ...bool) bool

func (*String) Float64

func (x *String) Float64(def ...float64) float64

func (*String) Int

func (x *String) Int(def ...int) int

func (*String) Int64

func (x *String) Int64(def ...int64) int64

func (*String) MarshalJSON

func (x *String) MarshalJSON() ([]byte, error)

func (*String) String

func (x *String) String(def ...string) string

func (*String) UnmarshalJSON

func (x *String) UnmarshalJSON(bytes []byte) error

func (*String) Valid

func (x *String) Valid() bool

func (*String) Value

func (x *String) Value(def ...string) string

type Time

type Time struct {
	// contains filtered or unexported fields
}

func NewTime

func NewTime(v ...time.Time) *Time

func (*Time) MarshalJSON

func (x *Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (x *Time) UnmarshalJSON(bytes []byte) error

func (*Time) Valid

func (x *Time) Valid() bool

func (*Time) Value

func (x *Time) Value(def ...time.Time) time.Time

type Tree

type Tree[T any] []*TreeNode[T]

Tree 树形结构

func Convert2Tree

func Convert2Tree[T Node](list []T, root string) Tree[T]

Convert2Tree 平铺数组转为树形结构

type TreeNode

type TreeNode[T any] struct {
	Id    string  `json:"id"`
	Pid   string  `json:"pid"`
	Data  T       `json:"data"`
	Child Tree[T] `json:"child"`
}

TreeNode 树形节点

type Trie

type Trie struct {
	// contains filtered or unexported fields
}

Trie Trie树

func NewTrie

func NewTrie() *Trie

NewTrie 创建前缀树

func (*Trie) Add

func (t *Trie) Add(sentence string, weight ...int)

Add 添加句子

func (*Trie) AddMap

func (t *Trie) AddMap(sentences map[string]int)

AddMap 添加

func (*Trie) AddSlice

func (t *Trie) AddSlice(sentences []string)

AddSlice 添加文本

func (*Trie) Check

func (t *Trie) Check(sentence string) (bool, int)

Check 判断是否包含

func (*Trie) Mask

func (t *Trie) Mask(sentence string) string

Mask 文本打码

func (*Trie) Update

func (t *Trie) Update(word string, weight int)

Update 更新权重

type TrieNode

type TrieNode struct {
	// contains filtered or unexported fields
}

TrieNode Trie树节点

type Value

type Value interface {
	Valid() bool
	String(def ...string) string
	Int(def ...int) int
	Int64(def ...int64) int64
	Float64(def ...float64) float64
	Bool(def ...bool) bool
}

func BoolValue

func BoolValue(v bool) Value

func Float64Value

func Float64Value(v float64) Value

func Int64Value

func Int64Value(v int64) Value

func IntValue

func IntValue(v int) Value

func NewValue

func NewValue(v any) Value

func StringValue

func StringValue(v string) Value

func ZeroValue

func ZeroValue() Value

type Zero

type Zero struct{}

func (*Zero) Bool

func (z *Zero) Bool(...bool) bool

func (*Zero) Float64

func (z *Zero) Float64(...float64) float64

func (*Zero) Int

func (z *Zero) Int(...int) int

func (*Zero) Int64

func (z *Zero) Int64(...int64) int64

func (*Zero) String

func (z *Zero) String(...string) string

func (*Zero) Valid

func (z *Zero) Valid() bool

Jump to

Keyboard shortcuts

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