From 8d84b733b836408e93685d0b1a38c7c758afb640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sat, 14 May 2022 15:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.go | 3 +++ string.go | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/init.go b/init.go index de1c566..60cb36e 100644 --- a/init.go +++ b/init.go @@ -18,6 +18,8 @@ var ( IP *ip // JSON ... JSON *ownJSON + // String ... + String *stringOperate ) func init() { @@ -26,4 +28,5 @@ func init() { Hash = &hash{} IP = &ip{} JSON = &ownJSON{} + String = &stringOperate{} } diff --git a/string.go b/string.go index 03c8473..33005f0 100644 --- a/string.go +++ b/string.go @@ -15,12 +15,20 @@ import ( "time" ) +// stringOperate ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:09 2022/5/14 +type stringOperate struct { +} + // GenRandomString 获取随机长度的字符串 // // Author : go_developer@163.com<白茶清欢> // // Date : 6:01 下午 2021/3/9 -func GenRandomString(source string, length uint) string { +func (s *stringOperate) GenRandomString(source string, length uint) string { if length == 0 { return "" } @@ -42,7 +50,7 @@ func GenRandomString(source string, length uint) string { // Author : go_developer@163.com<白茶清欢> // // Date : 6:01 下午 2021/3/9 -func Md5(str string) string { +func (s *stringOperate) Md5(str string) string { h := md5.New() _, _ = h.Write([]byte(str)) return hex.EncodeToString(h.Sum(nil)) @@ -53,7 +61,7 @@ func Md5(str string) string { // Author : go_developer@163.com<白茶清欢> // // Date : 4:58 下午 2021/10/25 -func SnakeCaseToCamel(str string) string { +func (s *stringOperate) SnakeCaseToCamel(str string) string { if len(str) == 0 { return "" }