Compare commits
3 Commits
8d056baada
...
feature/ge
Author | SHA1 | Date | |
---|---|---|---|
50aa5ae7f8 | |||
3533617196 | |||
9ff1c213bb |
2
any.go
2
any.go
@ -97,7 +97,7 @@ func (at *AnyType) ToString() String {
|
|||||||
case consts.DataTypeSliceAny:
|
case consts.DataTypeSliceAny:
|
||||||
var val []any
|
var val []any
|
||||||
_ = serialize.JSON.Transition(at.data, &val)
|
_ = serialize.JSON.Transition(at.data, &val)
|
||||||
return String(ArrayType[any](val).ToString().Value)
|
return String(ArrayType[any, any](val).ToString().Value)
|
||||||
case consts.DataTypeMapAnyAny:
|
case consts.DataTypeMapAnyAny:
|
||||||
return String(EasyMap(at.data).ToString())
|
return String(EasyMap(at.data).ToString())
|
||||||
case consts.DataTypeInt:
|
case consts.DataTypeInt:
|
||||||
|
64
array.go
64
array.go
@ -9,7 +9,9 @@ package wrapper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"git.zhangdeman.cn/zhangdeman/op_type"
|
"git.zhangdeman.cn/zhangdeman/op_type"
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -19,8 +21,8 @@ import (
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 21:03 2023/6/11
|
// Date : 21:03 2023/6/11
|
||||||
func ArrayType[Bt op_type.BaseType](value []Bt) *Array[Bt] {
|
func ArrayType[Bt op_type.BaseType, ExtractDataType op_type.BaseType](value []Bt) *Array[Bt, ExtractDataType] {
|
||||||
at := &Array[Bt]{
|
at := &Array[Bt, ExtractDataType]{
|
||||||
value: value,
|
value: value,
|
||||||
}
|
}
|
||||||
return at
|
return at
|
||||||
@ -31,7 +33,7 @@ func ArrayType[Bt op_type.BaseType](value []Bt) *Array[Bt] {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 21:05 2023/6/11
|
// Date : 21:05 2023/6/11
|
||||||
type Array[Bt op_type.BaseType] struct {
|
type Array[Bt op_type.BaseType, ExtractDataType op_type.BaseType] struct {
|
||||||
value []Bt
|
value []Bt
|
||||||
convertErr error
|
convertErr error
|
||||||
itemType reflect.Kind // 简单list场景下, 每一项的数据类型
|
itemType reflect.Kind // 简单list场景下, 每一项的数据类型
|
||||||
@ -42,7 +44,7 @@ type Array[Bt op_type.BaseType] struct {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 21:11 2023/6/11
|
// Date : 21:11 2023/6/11
|
||||||
func (at *Array[Bt]) IsNil() bool {
|
func (at *Array[Bt, ExtractDataType]) IsNil() bool {
|
||||||
return at.value == nil
|
return at.value == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ func (at *Array[Bt]) IsNil() bool {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 11:42 2024/4/22
|
// Date : 11:42 2024/4/22
|
||||||
func (at *Array[Bt]) ToStringSlice() []string {
|
func (at *Array[Bt, ExtractDataType]) ToStringSlice() []string {
|
||||||
list := make([]string, 0)
|
list := make([]string, 0)
|
||||||
for _, item := range at.value {
|
for _, item := range at.value {
|
||||||
byteData, _ := json.Marshal(item)
|
byteData, _ := json.Marshal(item)
|
||||||
@ -65,7 +67,7 @@ func (at *Array[Bt]) ToStringSlice() []string {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 17:43 2023/6/12
|
// Date : 17:43 2023/6/12
|
||||||
func (at *Array[Bt]) Unique() []Bt {
|
func (at *Array[Bt, ExtractDataType]) Unique() []Bt {
|
||||||
result := make([]Bt, 0)
|
result := make([]Bt, 0)
|
||||||
dataTable := make(map[string]bool)
|
dataTable := make(map[string]bool)
|
||||||
|
|
||||||
@ -90,7 +92,7 @@ func (at *Array[Bt]) Unique() []Bt {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 16:28 2023/7/31
|
// Date : 16:28 2023/7/31
|
||||||
func (at *Array[Bt]) Has(input Bt) int {
|
func (at *Array[Bt, ExtractDataType]) Has(input Bt) int {
|
||||||
for idx := 0; idx < len(at.value); idx++ {
|
for idx := 0; idx < len(at.value); idx++ {
|
||||||
if reflect.TypeOf(at.value[idx]).String() != reflect.TypeOf(input).String() {
|
if reflect.TypeOf(at.value[idx]).String() != reflect.TypeOf(input).String() {
|
||||||
// 类型不同
|
// 类型不同
|
||||||
@ -111,7 +113,7 @@ func (at *Array[Bt]) Has(input Bt) int {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 16:57 2023/9/28
|
// Date : 16:57 2023/9/28
|
||||||
func (at *Array[Bt]) ToString() StringResult {
|
func (at *Array[Bt, ExtractDataType]) ToString() StringResult {
|
||||||
if at.IsNil() {
|
if at.IsNil() {
|
||||||
return StringResult{
|
return StringResult{
|
||||||
Value: "",
|
Value: "",
|
||||||
@ -130,7 +132,7 @@ func (at *Array[Bt]) ToString() StringResult {
|
|||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 17:42 2023/10/25
|
// Date : 17:42 2023/10/25
|
||||||
func (at *Array[Bt]) ToStringWithSplit(split string) StringResult {
|
func (at *Array[Bt, ExtractDataType]) ToStringWithSplit(split string) StringResult {
|
||||||
if at.IsNil() {
|
if at.IsNil() {
|
||||||
return StringResult{
|
return StringResult{
|
||||||
Value: "",
|
Value: "",
|
||||||
@ -142,3 +144,47 @@ func (at *Array[Bt]) ToStringWithSplit(split string) StringResult {
|
|||||||
Err: nil,
|
Err: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExtractField 提取指定字段, 转换成数组
|
||||||
|
//
|
||||||
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
|
//
|
||||||
|
// Date : 15:24 2024/8/6
|
||||||
|
func (at *Array[Bt, ExtractDataType]) ExtractField(fieldPath string) ([]ExtractDataType, error) {
|
||||||
|
strValResult := at.ToString()
|
||||||
|
if nil != strValResult.Err {
|
||||||
|
return make([]ExtractDataType, 0), nil
|
||||||
|
}
|
||||||
|
gjsonResult := gjson.Parse(strValResult.Value)
|
||||||
|
if !gjsonResult.IsArray() {
|
||||||
|
return make([]ExtractDataType, 0), errors.New("input value is not slice")
|
||||||
|
}
|
||||||
|
arrList := gjsonResult.Array()
|
||||||
|
if len(arrList) == 0 {
|
||||||
|
return make([]ExtractDataType, 0), nil
|
||||||
|
}
|
||||||
|
res := make([]ExtractDataType, 0)
|
||||||
|
for _, item := range arrList {
|
||||||
|
valueResult := item.Get(fieldPath)
|
||||||
|
if !valueResult.Exists() {
|
||||||
|
// 不存在
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
var val ExtractDataType
|
||||||
|
if err := ConvertAssign(&val, valueResult.String()); nil != err {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
res = append(res, val)
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtractFieldIgnoreError 提取指定字段并忽略异常
|
||||||
|
//
|
||||||
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
|
//
|
||||||
|
// Date : 15:28 2024/8/6
|
||||||
|
func (at *Array[Bt, ExtractDataType]) ExtractFieldIgnoreError(field string) []ExtractDataType {
|
||||||
|
res, _ := at.ExtractField(field)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
@ -13,6 +13,24 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestArray_Unique(t *testing.T) {
|
func TestArray_Unique(t *testing.T) {
|
||||||
fmt.Println(ArrayType([]any{"1", 1, 1, "1", 2, 3}).Unique())
|
fmt.Println(ArrayType[any, any]([]any{"1", 1, 1, "1", 2, 3}).Unique())
|
||||||
fmt.Println(ArrayType([]int{1, 1, 2, 3}).Unique())
|
fmt.Println(ArrayType[int, any]([]int{1, 1, 2, 3}).Unique())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestArray_ExtractField(t *testing.T) {
|
||||||
|
testMap := []any{
|
||||||
|
map[string]any{
|
||||||
|
"age": 18,
|
||||||
|
"name": "baicha",
|
||||||
|
},
|
||||||
|
map[string]any{
|
||||||
|
"age": 20,
|
||||||
|
"name": "qinghuan",
|
||||||
|
},
|
||||||
|
map[string]any{
|
||||||
|
"foo": "bar",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
fmt.Println(ArrayType[any, int](testMap).ExtractField("age"))
|
||||||
|
fmt.Println(ArrayType[any, string](testMap).ExtractField("name"))
|
||||||
}
|
}
|
||||||
|
11
go.mod
11
go.mod
@ -5,22 +5,25 @@ go 1.21
|
|||||||
toolchain go1.21.4
|
toolchain go1.21.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240612081722-31c64d4d4ce7
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240726024939-e424db29c5c4
|
||||||
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211
|
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211
|
||||||
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0
|
git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20240122104027-4928421213c0
|
||||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240325080031-1f58204e8687
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240618035451-8d48a6bd39dd
|
||||||
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
|
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
|
||||||
|
github.com/spaolacci/murmur3 v1.1.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
|
github.com/tidwall/gjson v1.17.3
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20231227095334-7eb5cdbf9253 // indirect
|
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e // indirect
|
||||||
github.com/BurntSushi/toml v1.4.0 // indirect
|
github.com/BurntSushi/toml v1.4.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/go-ini/ini v1.67.0 // indirect
|
github.com/go-ini/ini v1.67.0 // indirect
|
||||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||||
github.com/mozillazg/go-pinyin v0.20.0 // indirect
|
github.com/mozillazg/go-pinyin v0.20.0 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
13
go.sum
13
go.sum
@ -8,6 +8,8 @@ git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240608124542-4d97bd80dc68 h1:AaWKU0
|
|||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240608124542-4d97bd80dc68/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240608124542-4d97bd80dc68/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240612081722-31c64d4d4ce7 h1:QR8vMXOTy0NFKdodsGKA4gTNHJMfob3yRFYMXrZj7ek=
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240612081722-31c64d4d4ce7 h1:QR8vMXOTy0NFKdodsGKA4gTNHJMfob3yRFYMXrZj7ek=
|
||||||
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240612081722-31c64d4d4ce7/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240612081722-31c64d4d4ce7/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
||||||
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240726024939-e424db29c5c4 h1:mibnyzYbZullK0aTHVASHl3UeoVr8IgytQZsuyv+yEM=
|
||||||
|
git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240726024939-e424db29c5c4/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k=
|
||||||
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240130062251-a87a97b0e8d4 h1:93JYY8JLbFcrlq37q/uKyxs2r2e3modsjvfSbnZQ/UI=
|
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240130062251-a87a97b0e8d4 h1:93JYY8JLbFcrlq37q/uKyxs2r2e3modsjvfSbnZQ/UI=
|
||||||
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240130062251-a87a97b0e8d4/go.mod h1:SrtvrQRdzt+8KfYzvosH++gWxo2ShPTzR1m3VQ6uX7U=
|
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240130062251-a87a97b0e8d4/go.mod h1:SrtvrQRdzt+8KfYzvosH++gWxo2ShPTzR1m3VQ6uX7U=
|
||||||
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211 h1:I/wOsRpCSRkU9vo1u703slQsmK0wnNeZzsWQOGtIAG0=
|
git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20240311030808-e2a2e6a3c211 h1:I/wOsRpCSRkU9vo1u703slQsmK0wnNeZzsWQOGtIAG0=
|
||||||
@ -18,8 +20,12 @@ git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240110090803-399e964daa0c h1:k7V
|
|||||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240110090803-399e964daa0c/go.mod h1:w7kG4zyTJ1uPFaTWhze+OQuaUBINT2XnDxpyiM6ctc0=
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240110090803-399e964daa0c/go.mod h1:w7kG4zyTJ1uPFaTWhze+OQuaUBINT2XnDxpyiM6ctc0=
|
||||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240325080031-1f58204e8687 h1:uQcGqdzi4UdpZlp4f4FUPeBqoygP58pEKJkmN3ROsE0=
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240325080031-1f58204e8687 h1:uQcGqdzi4UdpZlp4f4FUPeBqoygP58pEKJkmN3ROsE0=
|
||||||
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240325080031-1f58204e8687/go.mod h1:gf7SW2TXATgux8pfdFedMkXWv2515OtIIM/5c4atkFw=
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240325080031-1f58204e8687/go.mod h1:gf7SW2TXATgux8pfdFedMkXWv2515OtIIM/5c4atkFw=
|
||||||
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240618035451-8d48a6bd39dd h1:2Y37waOVCmVvx0Rp8VGEptE2/2JVMImtxB4dKKDk/3w=
|
||||||
|
git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240618035451-8d48a6bd39dd/go.mod h1:6+7whkCmb4sJDIfH3HxNuXRveaM0gCCNWd2uXZqNtIE=
|
||||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20231227095334-7eb5cdbf9253 h1:GO3oZa5a2sqwAzGcLDJtQzmshSWRmoP7IDS8bwFqvC4=
|
git.zhangdeman.cn/zhangdeman/util v0.0.0-20231227095334-7eb5cdbf9253 h1:GO3oZa5a2sqwAzGcLDJtQzmshSWRmoP7IDS8bwFqvC4=
|
||||||
git.zhangdeman.cn/zhangdeman/util v0.0.0-20231227095334-7eb5cdbf9253/go.mod h1:VpPjBlwz8U+OxZuxzHQBv1aEEZ3pStH6bZvT21ADEbI=
|
git.zhangdeman.cn/zhangdeman/util v0.0.0-20231227095334-7eb5cdbf9253/go.mod h1:VpPjBlwz8U+OxZuxzHQBv1aEEZ3pStH6bZvT21ADEbI=
|
||||||
|
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e h1:Q973S6CcWr1ICZhFI1STFOJ+KUImCl2BaIXm6YppBqI=
|
||||||
|
git.zhangdeman.cn/zhangdeman/util v0.0.0-20240618042405-6ee2c904644e/go.mod h1:VpPjBlwz8U+OxZuxzHQBv1aEEZ3pStH6bZvT21ADEbI=
|
||||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||||
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
|
||||||
@ -40,6 +46,13 @@ github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0b
|
|||||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
|
github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94=
|
||||||
|
github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
|
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||||
|
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
|
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
|
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||||
|
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
13
string.go
13
string.go
@ -13,6 +13,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"git.zhangdeman.cn/zhangdeman/serialize"
|
"git.zhangdeman.cn/zhangdeman/serialize"
|
||||||
"github.com/axgle/mahonia"
|
"github.com/axgle/mahonia"
|
||||||
|
"github.com/spaolacci/murmur3"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strings"
|
"strings"
|
||||||
@ -1175,3 +1176,15 @@ func (str String) HasSubStr(subStrList []string) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HashNumber ...
|
||||||
|
//
|
||||||
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
|
//
|
||||||
|
// Date : 11:05 2024/6/27
|
||||||
|
func (str String) HashNumber() Uint64Result {
|
||||||
|
return Uint64Result{
|
||||||
|
Value: murmur3.Sum64([]byte(str.Value())),
|
||||||
|
Err: nil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user