From 14d07bf96362a8e581274a6be00a2e2b2253bbd3 Mon Sep 17 00:00:00 2001 From: Yiwen-Chan Date: Thu, 1 Apr 2021 13:56:05 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20=E4=BF=AE=E5=A4=8D=20githu?= =?UTF-8?q?b=20repo=20=E6=90=9C=E7=B4=A2=E4=B8=AD=E6=96=87=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- github/repo_searcher.go | 8 +++++++- setutime/utils/utils.go | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/github/repo_searcher.go b/github/repo_searcher.go index aa61bb59..d67f5d7f 100644 --- a/github/repo_searcher.go +++ b/github/repo_searcher.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "net/http" + "net/url" "strings" "github.com/tidwall/gjson" @@ -13,7 +14,12 @@ import ( func init() { // 插件主体 zero.OnRegex(`>G\s(.*)`).SetBlock(true).SetPriority(0). Handle(func(ctx *zero.Ctx) { - link := "https://api.github.com/search/repositories?q=" + ctx.State["regex_matched"].([]string)[1] + api, _ := url.Parse("https://api.github.com/search/repositories") + params := url.Values{} + params.Set("q", ctx.State["regex_matched"].([]string)[1]) + api.RawQuery = params.Encode() + link := api.String() + client := &http.Client{} req, err := http.NewRequest("GET", link, nil) diff --git a/setutime/utils/utils.go b/setutime/utils/utils.go index 51c63055..24d75f74 100644 --- a/setutime/utils/utils.go +++ b/setutime/utils/utils.go @@ -8,8 +8,8 @@ import ( // Str2Int string --> int64 func Str2Int(str string) int64 { - val, _ := strconv.ParseInt(str, 10, 64) - return val + val, _ := strconv.Atoi(str) + return int64(val) } // Int2Str int64 --> string