Documentation ¶
Index ¶
- func AAA2Int(colName string) (colIndex int)
- func An2cn(an int) (string, error)
- func Avg[T Ordered](array []T) T
- func Cn2an(cn string) (int, error)
- func Contains[E comparable](array []E, ele E) bool
- func Equal[E comparable](a, b []E) (bool, int)
- func IndexS[E comparable](array []E, ele E) int
- func Insert[E comparable](array []E, index int, elem ...E) []E
- func Int2AAA(colIndex int) (colName string)
- func IsEmpty(array []string) bool
- func Max[E Ordered](array []E) E
- func Min[T Ordered](array []T) T
- func Pop[E comparable](array []E, index int) ([]E, E)
- func RepeatIndex[E comparable](array []E) map[E][]int
- type JsonString
- func (j JsonString) Check() bool
- func (j JsonString) Find(relational string) (any, error)
- func (j JsonString) FindBool(relational string) bool
- func (j JsonString) FindFloat(relational string) float64
- func (j JsonString) FindInt(relational string) int
- func (j JsonString) FindString(relational string) string
- type MD5
- type Ordered
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AAA2Int ¶
AAA2Int 将表格列名(string)转换为列索引(int)
Example ¶
s := AAA2Int("AAA") fmt.Println(s)
Output: 703
func Cn2an ¶
Cn2an 将中文数字转换为阿拉伯数字,不支持小数
Example ¶
n, _ := Cn2an("一万亿零六百万零二千四百") fmt.Println(n)
Output: 1000006002400
func Contains ¶
func Contains[E comparable](array []E, ele E) bool
Contains 判断切片 array 中是否包含元素 ele
Example ¶
fmt.Println(Contains([]string{"a", "B", "c"}, "a")) fmt.Println(Contains([]string{"a", "B", "c"}, "b"))
Output: true false
func Equal ¶
func Equal[E comparable](a, b []E) (bool, int)
Equal 简单比较两切片内元素是否相同,并返回第一个不相同索引
如果相同返回-2,如果长度不同返回-1
Example ¶
s, i := Equal([]string{"1"}, []string{"1"}) fmt.Println(s, i) s, i = Equal([]int{1}, []int{2}) fmt.Println(s, i)
Output: true -2 false 0
func IndexS ¶
func IndexS[E comparable](array []E, ele E) int
IndexS 判断切片 array 中元素 ele 的索引
Example ¶
fmt.Println(IndexS([]string{"a", "B", "c"}, "a")) fmt.Println(IndexS([]string{"a", "B", "c"}, "b"))
Output: 0 -1
func Insert ¶
func Insert[E comparable](array []E, index int, elem ...E) []E
Insert 向切片中插入元素,返回新的切片
Example ¶
a := []int{1, 2, 3, 4, 5} a = Insert(a, 2, 7, 8, 9) fmt.Println(a)
Output: [1 2 7 8 9 3 4 5]
func Int2AAA ¶
Int2AAA 将表格列索引(int)转换为列名(string)
Example ¶
s := Int2AAA(703) fmt.Println(s)
Output: AAA
func Pop ¶
func Pop[E comparable](array []E, index int) ([]E, E)
Pop 根据索引删除切片中的元素,返回新的切片,和删除的元素
Example ¶
a := []int{1, 2, 3, 4, 5} a, b := Pop(a, -3) fmt.Println(a, b)
Output: [1 2 4 5] 3
func RepeatIndex ¶
func RepeatIndex[E comparable](array []E) map[E][]int
RepeatIndex 提取切片内重复值的索引
Example ¶
a := []int{1, 3, 5, 7, 9, 2, 5, 3, 7, 1, 10} fmt.Println(RepeatIndex(a))
Output: map[1:[0 9] 3:[1 7] 5:[2 6] 7:[3 8]]
Types ¶
type JsonString ¶
type JsonString string
func (JsonString) Find ¶
func (j JsonString) Find(relational string) (any, error)
Find 查询方法
Example ¶
j := JsonString(`{"name":"jjs","age":18,"love":[123,45],"info":{"grade":7,"d":[60,70,80,90],"desc":"good"},"s":{"a":1,"b":2}}`) find, _ := j.Find("info.d.[0]") fmt.Println(find) find = j.FindInt("info.grade") fmt.Println(find)
Output: 60 7
func (JsonString) FindFloat ¶
func (j JsonString) FindFloat(relational string) float64
FindFloat 返回浮点数
func (JsonString) FindString ¶
func (j JsonString) FindString(relational string) string
FindString 返回字符串
type MD5 ¶
type MD5 string
MD5 代价密字符串
Example ¶
var s MD5 = "123456" fmt.Println(s.Encrypt()) fmt.Println(s.Encrypt().IsBig()) fmt.Println(s.Encrypt().IsShort().IsBig()) fmt.Printf("%T %s", s.Encrypt(), s.Encrypt().ToString())
Output: e10adc3949ba59abbe56e057f20f883e E10ADC3949BA59ABBE56E057F20F883E 49BA59ABBE56E057 data.MD5 e10adc3949ba59abbe56e057f20f883e
Click to show internal directories.
Click to hide internal directories.