feat: remove doc && update json tag
This commit is contained in:
255
string.go
255
string.go
@ -11,20 +11,17 @@ import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"git.zhangdeman.cn/zhangdeman/serialize"
|
||||
"github.com/axgle/mahonia"
|
||||
"github.com/spaolacci/murmur3"
|
||||
"io"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/serialize"
|
||||
"github.com/axgle/mahonia"
|
||||
"github.com/spaolacci/murmur3"
|
||||
)
|
||||
|
||||
// StringFromRandom 从随机字符串生成String
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:50 2023/8/11
|
||||
func StringFromRandom(length int, sourceCharList string) String {
|
||||
if length == 0 {
|
||||
return ""
|
||||
@ -36,24 +33,16 @@ func StringFromRandom(length int, sourceCharList string) String {
|
||||
strByte := []byte(sourceCharList)
|
||||
var genStrByte = make([]byte, 0)
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
for i := 0; i < int(length); i++ {
|
||||
for i := 0; i < length; i++ {
|
||||
genStrByte = append(genStrByte, strByte[r.Intn(len(strByte))])
|
||||
}
|
||||
return String(string(genStrByte))
|
||||
return String(genStrByte)
|
||||
}
|
||||
|
||||
// String 字符串类型包装
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:07 2023/5/5
|
||||
type String string
|
||||
|
||||
// ToFloat32 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:26 2023/5/4
|
||||
func (str String) ToFloat32() Float32Result {
|
||||
var (
|
||||
res Float32Result
|
||||
@ -63,10 +52,6 @@ func (str String) ToFloat32() Float32Result {
|
||||
}
|
||||
|
||||
// ToFloat32Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:58 2023/5/16
|
||||
func (str String) ToFloat32Ptr() Float32PtrResult {
|
||||
res := str.ToFloat32()
|
||||
if nil != res.Err {
|
||||
@ -82,10 +67,6 @@ func (str String) ToFloat32Ptr() Float32PtrResult {
|
||||
}
|
||||
|
||||
// ToFloat64 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:26 2023/5/4
|
||||
func (str String) ToFloat64() Float64Result {
|
||||
var (
|
||||
res Float64Result
|
||||
@ -95,10 +76,6 @@ func (str String) ToFloat64() Float64Result {
|
||||
}
|
||||
|
||||
// ToFloat64Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:59 2023/5/16
|
||||
func (str String) ToFloat64Ptr() Float64PtrResult {
|
||||
res := str.ToFloat64()
|
||||
if nil != res.Err {
|
||||
@ -114,46 +91,26 @@ func (str String) ToFloat64Ptr() Float64PtrResult {
|
||||
}
|
||||
|
||||
// ToDouble 转double
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:33 2023/5/4
|
||||
func (str String) ToDouble() Float64Result {
|
||||
return str.ToFloat64()
|
||||
}
|
||||
|
||||
// ToDoublePtr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:59 2023/5/16
|
||||
func (str String) ToDoublePtr() Float64PtrResult {
|
||||
return str.ToFloat64Ptr()
|
||||
}
|
||||
|
||||
// ToNumber 转数字, 使用最高精度的float64
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:33 2023/5/4
|
||||
func (str String) ToNumber() Float64Result {
|
||||
return str.ToFloat64()
|
||||
}
|
||||
|
||||
// ToNumberPtr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:00 2023/5/16
|
||||
func (str String) ToNumberPtr() Float64PtrResult {
|
||||
return str.ToFloat64Ptr()
|
||||
}
|
||||
|
||||
// ToInt8 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:29 2023/5/4
|
||||
func (str String) ToInt8() Int8Result {
|
||||
var (
|
||||
res Int8Result
|
||||
@ -163,10 +120,6 @@ func (str String) ToInt8() Int8Result {
|
||||
}
|
||||
|
||||
// ToInt8Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:01 2023/5/16
|
||||
func (str String) ToInt8Ptr() Int8PtrResult {
|
||||
res := str.ToInt8()
|
||||
if nil != res.Err {
|
||||
@ -182,10 +135,6 @@ func (str String) ToInt8Ptr() Int8PtrResult {
|
||||
}
|
||||
|
||||
// ToInt16 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:29 2023/5/4
|
||||
func (str String) ToInt16() Int16Result {
|
||||
var (
|
||||
res Int16Result
|
||||
@ -195,10 +144,6 @@ func (str String) ToInt16() Int16Result {
|
||||
}
|
||||
|
||||
// ToInt16Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:02 2023/5/16
|
||||
func (str String) ToInt16Ptr() Int16PtrResult {
|
||||
res := str.ToInt16()
|
||||
if nil != res.Err {
|
||||
@ -214,10 +159,6 @@ func (str String) ToInt16Ptr() Int16PtrResult {
|
||||
}
|
||||
|
||||
// ToInt32 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:29 2023/5/4
|
||||
func (str String) ToInt32() Int32Result {
|
||||
var (
|
||||
res Int32Result
|
||||
@ -227,10 +168,6 @@ func (str String) ToInt32() Int32Result {
|
||||
}
|
||||
|
||||
// ToInt32Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:03 2023/5/16
|
||||
func (str String) ToInt32Ptr() Int32PtrResult {
|
||||
res := str.ToInt32()
|
||||
if nil != res.Err {
|
||||
@ -246,10 +183,6 @@ func (str String) ToInt32Ptr() Int32PtrResult {
|
||||
}
|
||||
|
||||
// ToInt64 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:29 2023/5/4
|
||||
func (str String) ToInt64() Int64Result {
|
||||
var (
|
||||
res Int64Result
|
||||
@ -259,10 +192,6 @@ func (str String) ToInt64() Int64Result {
|
||||
}
|
||||
|
||||
// ToInt64Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:03 2023/5/16
|
||||
func (str String) ToInt64Ptr() Int64PtrResult {
|
||||
res := str.ToInt64()
|
||||
if nil != res.Err {
|
||||
@ -278,10 +207,6 @@ func (str String) ToInt64Ptr() Int64PtrResult {
|
||||
}
|
||||
|
||||
// ToInt ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:47 2023/5/5
|
||||
func (str String) ToInt() IntResult {
|
||||
var (
|
||||
res IntResult
|
||||
@ -310,10 +235,6 @@ func (str String) ToIntPtr() IntPtrResult {
|
||||
}
|
||||
|
||||
// ToUint8 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:30 2023/5/4
|
||||
func (str String) ToUint8() Uint8Result {
|
||||
var (
|
||||
res Uint8Result
|
||||
@ -323,10 +244,6 @@ func (str String) ToUint8() Uint8Result {
|
||||
}
|
||||
|
||||
// ToUint8Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:05 2023/5/16
|
||||
func (str String) ToUint8Ptr() Uint8PtrResult {
|
||||
res := str.ToUint8()
|
||||
if nil != res.Err {
|
||||
@ -342,10 +259,6 @@ func (str String) ToUint8Ptr() Uint8PtrResult {
|
||||
}
|
||||
|
||||
// ToUint16 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:29 2023/5/4
|
||||
func (str String) ToUint16() Uint16Result {
|
||||
var (
|
||||
res Uint16Result
|
||||
@ -355,10 +268,6 @@ func (str String) ToUint16() Uint16Result {
|
||||
}
|
||||
|
||||
// ToUint16Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:05 2023/5/16
|
||||
func (str String) ToUint16Ptr() Uint16PtrResult {
|
||||
res := str.ToUint16()
|
||||
if nil != res.Err {
|
||||
@ -374,10 +283,6 @@ func (str String) ToUint16Ptr() Uint16PtrResult {
|
||||
}
|
||||
|
||||
// ToUint32 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:29 2023/5/4
|
||||
func (str String) ToUint32() Uint32Result {
|
||||
var (
|
||||
res Uint32Result
|
||||
@ -387,10 +292,6 @@ func (str String) ToUint32() Uint32Result {
|
||||
}
|
||||
|
||||
// ToUint32Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:05 2023/5/16
|
||||
func (str String) ToUint32Ptr() Uint32PtrResult {
|
||||
res := str.ToUint32()
|
||||
if nil != res.Err {
|
||||
@ -406,10 +307,6 @@ func (str String) ToUint32Ptr() Uint32PtrResult {
|
||||
}
|
||||
|
||||
// ToUint64 ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:29 2023/5/4
|
||||
func (str String) ToUint64() Uint64Result {
|
||||
var (
|
||||
res Uint64Result
|
||||
@ -419,10 +316,6 @@ func (str String) ToUint64() Uint64Result {
|
||||
}
|
||||
|
||||
// ToUint64Ptr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:06 2023/5/16
|
||||
func (str String) ToUint64Ptr() Uint64PtrResult {
|
||||
res := str.ToUint64()
|
||||
if nil != res.Err {
|
||||
@ -438,10 +331,6 @@ func (str String) ToUint64Ptr() Uint64PtrResult {
|
||||
}
|
||||
|
||||
// ToUint ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:29 2023/5/4
|
||||
func (str String) ToUint() UintResult {
|
||||
var (
|
||||
res UintResult
|
||||
@ -451,10 +340,6 @@ func (str String) ToUint() UintResult {
|
||||
}
|
||||
|
||||
// ToUintPtr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:06 2023/5/16
|
||||
func (str String) ToUintPtr() UintPtrResult {
|
||||
res := str.ToUint()
|
||||
if nil != res.Err {
|
||||
@ -470,10 +355,6 @@ func (str String) ToUintPtr() UintPtrResult {
|
||||
}
|
||||
|
||||
// ToBool ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:34 2023/5/4
|
||||
func (str String) ToBool() BoolResult {
|
||||
var (
|
||||
res BoolResult
|
||||
@ -483,10 +364,6 @@ func (str String) ToBool() BoolResult {
|
||||
}
|
||||
|
||||
// ToBoolPtr ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:07 2023/5/16
|
||||
func (str String) ToBoolPtr() BoolPtrResult {
|
||||
res := str.ToBool()
|
||||
if nil != res.Err {
|
||||
@ -502,10 +379,6 @@ func (str String) ToBoolPtr() BoolPtrResult {
|
||||
}
|
||||
|
||||
// ToStringPtr 转换成字符串指针
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:57 2023/7/3
|
||||
func (str String) ToStringPtr() StringPtrResult {
|
||||
val := str.Value()
|
||||
return StringPtrResult{
|
||||
@ -531,10 +404,6 @@ func (str String) ToObject() ObjectResult {
|
||||
}
|
||||
|
||||
// ToStruct ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:38 2023/5/4
|
||||
func (str String) ToStruct(receiver any) error {
|
||||
if nil == receiver {
|
||||
return errors.New("receiver is nil")
|
||||
@ -543,10 +412,6 @@ func (str String) ToStruct(receiver any) error {
|
||||
}
|
||||
|
||||
// ToInt8Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:55 2023/5/4
|
||||
func (str String) ToInt8Slice(splitChar ...string) Int8SliceResult {
|
||||
result := Int8SliceResult{
|
||||
Value: []int8{},
|
||||
@ -575,10 +440,6 @@ func (str String) ToInt8Slice(splitChar ...string) Int8SliceResult {
|
||||
}
|
||||
|
||||
// ToInt16Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:01 2023/5/4
|
||||
func (str String) ToInt16Slice(splitChar ...string) Int16SliceResult {
|
||||
|
||||
result := Int16SliceResult{
|
||||
@ -606,10 +467,6 @@ func (str String) ToInt16Slice(splitChar ...string) Int16SliceResult {
|
||||
}
|
||||
|
||||
// ToInt32Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:03 2023/5/4
|
||||
func (str String) ToInt32Slice(splitChar ...string) Int32SliceResult {
|
||||
result := Int32SliceResult{
|
||||
Value: []int32{},
|
||||
@ -636,10 +493,6 @@ func (str String) ToInt32Slice(splitChar ...string) Int32SliceResult {
|
||||
}
|
||||
|
||||
// ToInt64Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:04 2023/5/4
|
||||
func (str String) ToInt64Slice(splitChar ...string) Int64SliceResult {
|
||||
result := Int64SliceResult{
|
||||
Value: []int64{},
|
||||
@ -665,10 +518,6 @@ func (str String) ToInt64Slice(splitChar ...string) Int64SliceResult {
|
||||
}
|
||||
|
||||
// ToIntSlice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 19:04 2023/5/4
|
||||
func (str String) ToIntSlice(splitChar ...string) IntSliceResult {
|
||||
result := IntSliceResult{
|
||||
Value: []int{},
|
||||
@ -695,10 +544,6 @@ func (str String) ToIntSlice(splitChar ...string) IntSliceResult {
|
||||
}
|
||||
|
||||
// ToUint8Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:50 2023/5/5
|
||||
func (str String) ToUint8Slice(splitChar ...string) Uint8SliceResult {
|
||||
result := Uint8SliceResult{
|
||||
Value: []uint8{},
|
||||
@ -725,10 +570,6 @@ func (str String) ToUint8Slice(splitChar ...string) Uint8SliceResult {
|
||||
}
|
||||
|
||||
// ToUint16Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:52 2023/5/5
|
||||
func (str String) ToUint16Slice(splitChar ...string) Uint16SliceResult {
|
||||
result := Uint16SliceResult{
|
||||
Value: []uint16{},
|
||||
@ -755,10 +596,6 @@ func (str String) ToUint16Slice(splitChar ...string) Uint16SliceResult {
|
||||
}
|
||||
|
||||
// ToUint32Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:53 2023/5/5
|
||||
func (str String) ToUint32Slice(splitChar ...string) Uint32SliceResult {
|
||||
result := Uint32SliceResult{
|
||||
Value: []uint32{},
|
||||
@ -785,10 +622,6 @@ func (str String) ToUint32Slice(splitChar ...string) Uint32SliceResult {
|
||||
}
|
||||
|
||||
// ToUint64Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:54 2023/5/5
|
||||
func (str String) ToUint64Slice(splitChar ...string) Uint64SliceResult {
|
||||
result := Uint64SliceResult{
|
||||
Value: []uint64{},
|
||||
@ -814,10 +647,6 @@ func (str String) ToUint64Slice(splitChar ...string) Uint64SliceResult {
|
||||
}
|
||||
|
||||
// ToUintSlice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:54 2023/5/5
|
||||
func (str String) ToUintSlice(splitChar ...string) UintSliceResult {
|
||||
result := UintSliceResult{
|
||||
Value: []uint{},
|
||||
@ -844,10 +673,6 @@ func (str String) ToUintSlice(splitChar ...string) UintSliceResult {
|
||||
}
|
||||
|
||||
// ToBoolSlice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:55 2023/5/5
|
||||
func (str String) ToBoolSlice(splitChar ...string) BoolSliceResult {
|
||||
result := BoolSliceResult{
|
||||
Value: []bool{},
|
||||
@ -874,10 +699,6 @@ func (str String) ToBoolSlice(splitChar ...string) BoolSliceResult {
|
||||
}
|
||||
|
||||
// ToFloat32Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:56 2023/5/5
|
||||
func (str String) ToFloat32Slice(splitChar ...string) Float32SliceResult {
|
||||
result := Float32SliceResult{
|
||||
Value: []float32{},
|
||||
@ -903,10 +724,6 @@ func (str String) ToFloat32Slice(splitChar ...string) Float32SliceResult {
|
||||
}
|
||||
|
||||
// ToFloat64Slice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:56 2023/5/5
|
||||
func (str String) ToFloat64Slice(splitChar ...string) Float64SliceResult {
|
||||
result := Float64SliceResult{
|
||||
Value: []float64{},
|
||||
@ -933,28 +750,16 @@ func (str String) ToFloat64Slice(splitChar ...string) Float64SliceResult {
|
||||
}
|
||||
|
||||
// ToDoubleSlice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:57 2023/5/5
|
||||
func (str String) ToDoubleSlice(splitChar ...string) Float64SliceResult {
|
||||
return str.ToFloat64Slice(splitChar...)
|
||||
}
|
||||
|
||||
// ToNumberSlice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 10:57 2023/5/5
|
||||
func (str String) ToNumberSlice(splitChar ...string) Float64SliceResult {
|
||||
return str.ToFloat64Slice(splitChar...)
|
||||
}
|
||||
|
||||
// ToDuration 转换为时间格式
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 20:31 2023/9/4
|
||||
func (str String) ToDuration(timeUnit time.Duration) DurationResult {
|
||||
int64Val := str.ToInt64()
|
||||
if nil != int64Val.Err {
|
||||
@ -967,10 +772,6 @@ func (str String) ToDuration(timeUnit time.Duration) DurationResult {
|
||||
}
|
||||
|
||||
// ToStringSlice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:11 2023/8/6
|
||||
func (str String) ToStringSlice(splitChar ...string) StringSliceResult {
|
||||
result := StringSliceResult{
|
||||
Value: []string{},
|
||||
@ -987,10 +788,6 @@ func (str String) ToStringSlice(splitChar ...string) StringSliceResult {
|
||||
}
|
||||
|
||||
// ToAnySlice ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:01 2023/5/5
|
||||
func (str String) ToAnySlice(splitCharList ...string) AnySliceResult {
|
||||
result := AnySliceResult{
|
||||
Value: []any{},
|
||||
@ -1023,10 +820,6 @@ func (str String) ToAnySlice(splitCharList ...string) AnySliceResult {
|
||||
}
|
||||
|
||||
// Md5 计算Md5值
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:08 2023/5/16
|
||||
func (str String) Md5() StringResult {
|
||||
h := md5.New()
|
||||
_, err := io.WriteString(h, str.Value())
|
||||
@ -1043,19 +836,11 @@ func (str String) Md5() StringResult {
|
||||
}
|
||||
|
||||
// Value ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:11 2023/5/16
|
||||
func (str String) Value() string {
|
||||
return string(str)
|
||||
}
|
||||
|
||||
// GetLetterList 获取字母列表
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:53 2023/8/11
|
||||
func (str String) GetLetterList() []string {
|
||||
return []string{
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
|
||||
@ -1064,10 +849,6 @@ func (str String) GetLetterList() []string {
|
||||
}
|
||||
|
||||
// SnakeCaseToCamel 蛇形字符串转换为驼峰
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 4:58 下午 2021/10/25
|
||||
func (str String) SnakeCaseToCamel() string {
|
||||
if len(str) == 0 {
|
||||
return ""
|
||||
@ -1097,10 +878,6 @@ func (str String) SnakeCaseToCamel() string {
|
||||
}
|
||||
|
||||
// Convert 字符串编码转换
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:38 2022/7/9
|
||||
func (str String) Convert(sourceCode string, targetCode string) String {
|
||||
sourceCoder := mahonia.NewDecoder(sourceCode)
|
||||
sourceResult := sourceCoder.ConvertString(str.Value())
|
||||
@ -1110,10 +887,6 @@ func (str String) Convert(sourceCode string, targetCode string) String {
|
||||
}
|
||||
|
||||
// ClearChar 清理指定字符
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:59 2023/8/11
|
||||
func (str String) ClearChar(charList ...string) String {
|
||||
if len(charList) == 0 {
|
||||
return str
|
||||
@ -1126,10 +899,6 @@ func (str String) ClearChar(charList ...string) String {
|
||||
}
|
||||
|
||||
// ReplaceChineseChar 替换常见的中文符号
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 16:59 2023/4/4
|
||||
func (str String) ReplaceChineseChar() String {
|
||||
charTable := map[string]string{
|
||||
"(": "(",
|
||||
@ -1144,10 +913,6 @@ func (str String) ReplaceChineseChar() String {
|
||||
}
|
||||
|
||||
// ReplaceChar 替换指定字符
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:01 2023/8/11
|
||||
func (str String) ReplaceChar(charTable map[string]string) String {
|
||||
if len(charTable) == 0 {
|
||||
return str
|
||||
@ -1160,10 +925,6 @@ func (str String) ReplaceChar(charTable map[string]string) String {
|
||||
}
|
||||
|
||||
// HasSubStr 是否包含指定的子串
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 18:37 2024/4/19
|
||||
func (str String) HasSubStr(subStrList []string) bool {
|
||||
if len(subStrList) == 0 {
|
||||
return true
|
||||
@ -1178,10 +939,6 @@ func (str String) HasSubStr(subStrList []string) bool {
|
||||
}
|
||||
|
||||
// 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())),
|
||||
|
Reference in New Issue
Block a user