From 155a58819c3a5be36afdc403af605a004b4b697a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Sun, 20 Mar 2022 11:21:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=88=A0=E9=99=A4=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/goarray/goarray_test.go | 8 -- utils/gobase64/gobase64_test.go | 13 ---- utils/godecimal/godecimal_test.go | 9 --- utils/gohttp/gohttp_test.go | 13 ---- utils/goint/goint_test.go | 13 ---- utils/goint64/goint64_test.go | 1 - utils/golog/golog_test.go | 33 -------- utils/gomd5/gomd5_test.go | 11 --- utils/gophp/gophp_test.go | 41 ---------- utils/gopreg/gopreg_test.go | 7 -- utils/gorandom/gorandom_test.go | 22 ------ utils/gorequest/gorequest_test.go | 9 --- utils/gossh/gossh_test.go | 9 --- utils/gostring/gostring_test.go | 39 ---------- utils/gotime/app_test.go | 124 ------------------------------ utils/gourl/gourl_test.go | 68 ---------------- utils/gouuid/gouuid_test.go | 23 ------ 17 files changed, 443 deletions(-) delete mode 100644 utils/goarray/goarray_test.go delete mode 100644 utils/gobase64/gobase64_test.go delete mode 100644 utils/godecimal/godecimal_test.go delete mode 100644 utils/gohttp/gohttp_test.go delete mode 100644 utils/goint/goint_test.go delete mode 100644 utils/goint64/goint64_test.go delete mode 100644 utils/golog/golog_test.go delete mode 100644 utils/gomd5/gomd5_test.go delete mode 100644 utils/gophp/gophp_test.go delete mode 100644 utils/gopreg/gopreg_test.go delete mode 100644 utils/gorandom/gorandom_test.go delete mode 100644 utils/gorequest/gorequest_test.go delete mode 100644 utils/gossh/gossh_test.go delete mode 100644 utils/gostring/gostring_test.go delete mode 100644 utils/gotime/app_test.go delete mode 100644 utils/gourl/gourl_test.go delete mode 100644 utils/gouuid/gouuid_test.go diff --git a/utils/goarray/goarray_test.go b/utils/goarray/goarray_test.go deleted file mode 100644 index 2fb62b75..00000000 --- a/utils/goarray/goarray_test.go +++ /dev/null @@ -1,8 +0,0 @@ -package goarray - -import "testing" - -func TestName(t *testing.T) { - ss := []string{"c2:37:7d:2b:78:c3", "c2:37:7d:2b:78:c4", "14:98:77:5a:58:66", "c2:37:7d:2b:78:a3", "c2:37:7d:2b:78:a4", "36:ce:4f:d2:84:00", "36:ce:4f:d2:84:04", "36:98:77:50:03:1b", "14:98:77:50:03:1b", "36:ce:4f:d2:84:00", "e2:ed:05:15:9c:2a", "e2:ed:05:15:9c:2a"} - t.Log(TurnString(ss)) -} diff --git a/utils/gobase64/gobase64_test.go b/utils/gobase64/gobase64_test.go deleted file mode 100644 index 061d94dc..00000000 --- a/utils/gobase64/gobase64_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package gobase64 - -import ( - "testing" -) - -func TestEncode(t *testing.T) { - t.Log(Encode("广东茂名")) -} - -func TestDecode(t *testing.T) { - t.Log(Decode(Encode("广东茂名"))) -} diff --git a/utils/godecimal/godecimal_test.go b/utils/godecimal/godecimal_test.go deleted file mode 100644 index ad5cda15..00000000 --- a/utils/godecimal/godecimal_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package godecimal - -import ( - "testing" -) - -func TestName(t *testing.T) { - t.Log(Decimal(2.3333)) -} diff --git a/utils/gohttp/gohttp_test.go b/utils/gohttp/gohttp_test.go deleted file mode 100644 index a8b6ce82..00000000 --- a/utils/gohttp/gohttp_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package gohttp - -import ( - "testing" -) - -func TestName(t *testing.T) { - get, err := Get("https://api.dtapp.net/", nil) - t.Logf("%+v\n", get) - if err != nil { - return - } -} diff --git a/utils/goint/goint_test.go b/utils/goint/goint_test.go deleted file mode 100644 index 7c93ce04..00000000 --- a/utils/goint/goint_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package goint - -import ( - "testing" -) - -func TestToString(t *testing.T) { - t.Log(ToString(9898)) -} - -func TestToFloat64(t *testing.T) { - t.Log(ToFloat64(9898)) -} diff --git a/utils/goint64/goint64_test.go b/utils/goint64/goint64_test.go deleted file mode 100644 index 5c56c7f8..00000000 --- a/utils/goint64/goint64_test.go +++ /dev/null @@ -1 +0,0 @@ -package goint64 diff --git a/utils/golog/golog_test.go b/utils/golog/golog_test.go deleted file mode 100644 index 7591db30..00000000 --- a/utils/golog/golog_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package golog - -import ( - "log" - "testing" -) - -var app = App{ - LogPath: "./", - LogName: "all.log", - LogLevel: "debug", - MaxSize: 2, - MaxBackups: 30, - MaxAge: 0, - Compress: false, - JsonFormat: false, - ShowLine: true, - LogInConsole: true, -} - -func TestLog(t *testing.T) { - log.Println(app.Logger) - app.InitLogger() - app.Logger.Debug("debug 日志") - app.Logger.Sugar().Debug("debug 日志") - app.Logger.Info("info 日志") - app.Logger.Sugar().Info("info 日志") - app.Logger.Warn("warning 日志") - app.Logger.Sugar().Warn("warning 日志") - app.Logger.Error("error 日志") - app.Logger.Sugar().Error("error 日志") - log.Println(app.Logger) -} diff --git a/utils/gomd5/gomd5_test.go b/utils/gomd5/gomd5_test.go deleted file mode 100644 index f8853b53..00000000 --- a/utils/gomd5/gomd5_test.go +++ /dev/null @@ -1,11 +0,0 @@ -package gomd5 - -import ( - "testing" -) - -func TestMd5(t *testing.T) { - t.Logf(GetMD5Encode("测试")) - t.Logf(ToUpper(GetMD5Encode("测试"))) - t.Logf(ToUpper("测试")) -} diff --git a/utils/gophp/gophp_test.go b/utils/gophp/gophp_test.go deleted file mode 100644 index caecb92b..00000000 --- a/utils/gophp/gophp_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package gophp - -import ( - "encoding/json" - "fmt" - "testing" -) - -func TestPhp(t *testing.T) { - fmt.Println(Unserialize([]byte(`a:1:{s:4:"test";i:34343;}`))) - serialize, _ := Serialize(map[string]interface{}{ - "test": 34343, - }) - fmt.Println(string(serialize)) -} - -type student struct { - Amount string `json:"amount"` - CreateTime string `json:"create_time"` - UpdateTime string `json:"update_time"` - UserID string `json:"user_id"` -} - -func TestUnserialize(t *testing.T) { - unserialize, _ := Unserialize([]byte(`a:2:{i:0;a:4:{s:7:"user_id";s:5:"10118";s:6:"amount";s:5:"69.00";s:11:"create_time";s:19:"2021-01-04 16:29:03";s:11:"update_time";s:19:"2021-06-15 16:02:46";}i:1;a:4:{s:7:"user_id";s:5:"10088";s:6:"amount";s:5:"10.00";s:11:"create_time";s:19:"2021-01-04 15:46:10";s:11:"update_time";s:19:"2021-06-15 15:50:06";}}`)) - fmt.Printf("%s\n", unserialize) - arr, _ := json.Marshal(unserialize) - fmt.Printf("arr:%s\n", arr) - var stu []student - _ = json.Unmarshal(arr, &stu) - fmt.Printf("stu:%v\n", stu) -} - -func TestUnserialize2(t *testing.T) { - unserialize, err := Unserialize([]byte(`a:3:{s:4:"self";a:5:{s:2:"id";i:32;s:7:"user_id";i:10118;s:16:"merchant_user_id";i:10150;s:5:"level";i:3;s:5:"split";d:2.825;}s:5:"split";a:2:{i:0;a:7:{s:2:"id";i:12;s:7:"user_id";i:10000;s:13:"agent_user_id";i:10088;s:16:"user_golden_bean";d:5;s:5:"level";i:1;s:11:"calculation";d:0.010000000000000002;s:5:"split";d:0.57;}i:1;a:7:{s:2:"id";i:19;s:7:"user_id";i:10088;s:13:"agent_user_id";i:10118;s:16:"user_golden_bean";d:4;s:5:"level";i:2;s:11:"calculation";d:0.04;s:5:"split";d:2.26;}}s:11:"golden_bean";a:6:{s:4:"fans";d:56.5;s:12:"fan_referrer";d:16.95;s:8:"merchant";d:4.5200000000000005;s:5:"agent";d:2.825;s:5:"count";d:80.795;s:2:"bf";a:9:{s:2:"id";i:2;s:7:"user_id";i:10088;s:4:"fans";d:50;s:12:"fan_referrer";d:30;s:8:"merchant";d:8;s:6:"system";d:0;s:5:"agent";d:5;s:11:"create_time";s:19:"2020-11-20 14:47:21";s:11:"update_time";s:19:"2020-11-20 14:47:21";}}}`)) - fmt.Printf("%+v\n", unserialize) - if err != nil { - fmt.Printf("err:%v\n", err) - return - } -} diff --git a/utils/gopreg/gopreg_test.go b/utils/gopreg/gopreg_test.go deleted file mode 100644 index e96eb1e8..00000000 --- a/utils/gopreg/gopreg_test.go +++ /dev/null @@ -1,7 +0,0 @@ -package gopreg - -import "testing" - -func TestName(t *testing.T) { - -} diff --git a/utils/gorandom/gorandom_test.go b/utils/gorandom/gorandom_test.go deleted file mode 100644 index 37670516..00000000 --- a/utils/gorandom/gorandom_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package gorandom - -import ( - "fmt" - "testing" -) - -func TestAlphanumeric(t *testing.T) { - fmt.Println(Alphanumeric(10)) -} - -func TestAlphabetic(t *testing.T) { - fmt.Println(Alphabetic(10)) -} - -func TestNumeric(t *testing.T) { - fmt.Println(Numeric(10)) -} - -func TestAscii(t *testing.T) { - fmt.Println(Ascii(10)) -} diff --git a/utils/gorequest/gorequest_test.go b/utils/gorequest/gorequest_test.go deleted file mode 100644 index 0202896f..00000000 --- a/utils/gorequest/gorequest_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package gorequest - -import ( - "testing" -) - -func TestExternalIp(t *testing.T) { - t.Log(ExternalIp()) -} diff --git a/utils/gossh/gossh_test.go b/utils/gossh/gossh_test.go deleted file mode 100644 index fc1731ad..00000000 --- a/utils/gossh/gossh_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package gossh - -import ( - "testing" -) - -func TestClient(t *testing.T) { - //Tunnel("root", "", ":22", ":3306", "localhost:13306") -} diff --git a/utils/gostring/gostring_test.go b/utils/gostring/gostring_test.go deleted file mode 100644 index 10f73ee2..00000000 --- a/utils/gostring/gostring_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package gostring - -import ( - "fmt" - "strings" - "testing" -) - -func TestName(t *testing.T) { - str := "iPhone 11 Pro Max" - fmt.Printf("%d\n", strings.LastIndex(str, "<")) - fmt.Printf("%d\n", strings.LastIndex(str, "(")) - fmt.Printf("%d\n", strings.LastIndex("iPad (6th generation, WiFi)", "<")) - fmt.Printf("%d\n", strings.LastIndex("iPad (6th generation, WiFi)", "(")) - s := str[0:17] - fmt.Printf("%s\n", s) - str = "iPad (6th generation, WiFi)" - s = str[0:5] - fmt.Printf("%s\n", s) - fmt.Printf(strings.TrimSpace(s)) -} - -func TestToInt64(t *testing.T) { - t.Log(ToInt64("120")) - t.Log(ToInt64("120.9")) - t.Log(strings.Contains("120", ",")) - t.Log(strings.Contains("120,1", ",")) -} - -func TestString(t *testing.T) { - str := "wx6566ef69e8738ad9" - fmt.Println(strings.Contains(str, "wx")) - myString := "www.dtapp.net" - if strings.HasPrefix(myString, "www") { - fmt.Println("Hello to you too") - } else { - fmt.Println("Goodbye") - } -} diff --git a/utils/gotime/app_test.go b/utils/gotime/app_test.go deleted file mode 100644 index 5fb7ea83..00000000 --- a/utils/gotime/app_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package gotime - -import ( - "testing" -) - -func TestTime(t *testing.T) { - t.Log("今天此刻:", Current().Now()) - t.Log("今天此刻格式化:", Current().Format()) - t.Log("今天此刻日期:", Current().ToDateFormat()) - t.Log("今天此刻时间:", Current().ToTimeFormat()) - t.Log("今天此刻时间戳:", Current().Timestamp()) - t.Log("今天此刻时间戳:", Current().TimestampWithSecond()) - t.Log("今天毫秒级时间戳:", Current().TimestampWithMillisecond()) - t.Log("今天微秒级时间戳:", Current().TimestampWithMicrosecond()) - t.Log("今天纳秒级时间戳:", Current().TimestampWithNanosecond()) - - t.Log("昨天此刻:", Yesterday().Now()) - t.Log("昨天此刻格式化:", Yesterday().Format()) - t.Log("昨天此刻日期:", Yesterday().ToDateFormat()) - t.Log("昨天此刻时间:", Yesterday().ToTimeFormat()) - t.Log("昨天此刻时间戳:", Yesterday().Timestamp()) - t.Log("昨天此刻时间戳:", Yesterday().TimestampWithSecond()) - t.Log("昨天毫秒级时间戳:", Yesterday().TimestampWithMillisecond()) - t.Log("昨天微秒级时间戳:", Yesterday().TimestampWithMicrosecond()) - t.Log("昨天纳秒级时间戳:", Yesterday().TimestampWithNanosecond()) - - t.Log("明天此刻:", Tomorrow().Now()) - t.Log("明天此刻格式化:", Tomorrow().Format()) - t.Log("明天此刻日期:", Tomorrow().ToDateFormat()) - t.Log("明天此刻时间:", Tomorrow().ToTimeFormat()) - t.Log("明天此刻时间戳:", Tomorrow().Timestamp()) - t.Log("明天此刻时间戳:", Tomorrow().TimestampWithSecond()) - t.Log("明天毫秒级时间戳:", Tomorrow().TimestampWithMillisecond()) - t.Log("明天微秒级时间戳:", Tomorrow().TimestampWithMicrosecond()) - t.Log("明天纳秒级时间戳:", Tomorrow().TimestampWithNanosecond()) - - t.Log("本世纪开始时间:", Current().StartOfCentury().Format()) - t.Log("本世纪结束时间:", Current().EndOfCentury().Format()) - t.Log("本年代开始时间:", Current().StartOfDecade().Format()) - t.Log("本年代结束时间:", Current().EndOfDecade().Format()) - t.Log("本年开始时间:", Current().StartOfYear().Format()) - t.Log("本年结束时间:", Current().EndOfYear().Format()) - t.Log("本季度开始时间:", Current().StartOfQuarter().Format()) - t.Log("本季度结束时间:", Current().EndOfQuarter().Format()) - t.Log("本月开始时间:", Current().StartOfMonth().Format()) - t.Log("本月结束时间:", Current().EndOfMonth().Format()) - - //t.Log("7100秒前的时间:", Current().BeforeSeconds(7100).Format()) - //t.Log("2小时前的时间:", Current().BeforeHour(2).Format()) - //t.Log("7100秒后的时间:", Current().AfterSeconds(7100).Format()) - //t.Log("2小时后的时间:", Current().AfterHour(2).Format()) -} - -func TestStartOfDay(t *testing.T) { - t.Log(Current().Format()) - t.Log(Current().StartOfDay().Format()) - t.Log(Current().EndOfDay().Format()) - t.Log(Current().Timestamp()) - t.Log(Current().StartOfDay().Timestamp()) - t.Log(Current().EndOfDay().Timestamp()) - t.Log(Current().BeforeDay(1).Format()) - t.Log(Current().BeforeDay(1).StartOfDay().Format()) - t.Log(Current().BeforeDay(1).EndOfDay().Format()) - t.Log(Current().AfterDay(1).Format()) - t.Log(Current().AfterDay(1).StartOfDay().Format()) - t.Log(Current().AfterDay(1).EndOfDay().Format()) -} - -func TestDiff(t *testing.T) { - t.Log(Current().DiffInHourWithAbs(SetCurrentParse("2021-11-26 14:50:00").Time)) - t.Log(Current().DiffInHour(SetCurrentParse("2021-11-26 14:50:00").Time)) - t.Log(Current().DiffInMinutesWithAbs(SetCurrentParse("2021-11-26 14:50:00").Time)) - t.Log(Current().DiffInMinutes(SetCurrentParse("2021-11-26 14:50:00").Time)) - t.Log(SetCurrentParse("2022-03-01T10:03:39+08:00").Format()) - t.Log(SetCurrentParse("2022-03-04T11:12:47+08:00").Format()) -} - -func TestUnix(t *testing.T) { - t.Log(SetCurrentUnix(1640067240).Format()) - t.Log(Current().BeforeDay(3 - 2).StartOfDay().Format()) - t.Log(Current().BeforeDay(3 - 1).EndOfDay().Format()) -} - -func Test2(t *testing.T) { - t.Log(Current().BeforeDay(1 + 1).Format()) - t.Log(Current().BeforeDay(1).Format()) - t.Log(Current().BeforeHour(24).Format()) - t.Log(Current().Format()) -} - -func TestTaoBao(t *testing.T) { - i := 1 - for { - if i > 3 { - break - } - t.Log(i) - t.Log(i * 24) - t.Log((i * 24) - 24) - t.Log(Current().BeforeHour(i * 24).Format()) - t.Log(Current().BeforeHour((i * 24) - 24).Format()) - i++ - } -} - -func TestMT(t *testing.T) { - - day := 1 - t.Log(day) - t.Log(Current().BeforeHour(24 * day).Format()) - t.Log(Current().BeforeHour(24 * (day - 1)).Format()) - - day = 2 - t.Log(day) - t.Log(Current().BeforeHour(24 * day).Format()) - t.Log(Current().BeforeHour(24 * (day - 1)).Format()) - - day = 3 - t.Log(day) - t.Log(Current().BeforeHour(24 * day).Format()) - t.Log(Current().BeforeHour(24 * (day - 1)).Format()) - -} diff --git a/utils/gourl/gourl_test.go b/utils/gourl/gourl_test.go deleted file mode 100644 index 632a83b5..00000000 --- a/utils/gourl/gourl_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package gourl - -import ( - "testing" - "time" -) - -func TestLenCode(t *testing.T) { - type args struct { - s string - } - tests := []struct { - name string - args args - want string - }{{ - name: "https://www.dtapp.net", - }, { - name: "https://www.dtapp.net", - }, { - name: "https://www.dtapp.net", - }} - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - start := time.Now() - t.Log(LenCode(tt.name)) - elapsed := time.Since(start) - t.Log("run time", elapsed) - }) - } -} - -func BenchmarkLenCode(b *testing.B) { - for n := 0; n < b.N; n++ { - LenCode("https://www.dtapp.net") - } -} - -func TestDeCode(t *testing.T) { - type args struct { - s string - } - tests := []struct { - name string - args args - want string - }{{ - name: "https%3A%2F%2Fwww.dtapp.net", - }, { - name: "https%3A%2F%2Fwww.dtapp.net", - }, { - name: "https%3A%2F%2Fwww.dtapp.net", - }} - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - start := time.Now() - t.Log(DeCode(tt.name)) - elapsed := time.Since(start) - t.Log("run time", elapsed) - }) - } -} - -func BenchmarkDeCode(b *testing.B) { - for n := 0; n < b.N; n++ { - DeCode("https%3A%2F%2Fwww.dtapp.net") - } -} diff --git a/utils/gouuid/gouuid_test.go b/utils/gouuid/gouuid_test.go deleted file mode 100644 index 36e39e17..00000000 --- a/utils/gouuid/gouuid_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package gouuid - -import ( - "testing" -) - -func TestGetUuId(t *testing.T) { - tests := []struct { - name string - want string - }{{}, {}, {}} - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - t.Log(GetUuId()) - }) - } -} - -func BenchmarkGetUuId(b *testing.B) { - for n := 0; n < b.N; n++ { - GetUuId() - } -}