From 096b1552f49bf123feb62966cfecb871934b5859 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:48:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.go | 3 +++ url.go | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/init.go b/init.go index d33d6a7..ac19126 100644 --- a/init.go +++ b/init.go @@ -24,6 +24,8 @@ var ( Struct *ownStruct // Time ... Time *ownTime + // URL ... + URL *ownURL ) func init() { @@ -35,4 +37,5 @@ func init() { String = &stringOperate{} Struct = &ownStruct{} Time = &ownTime{} + URL = &ownURL{} } diff --git a/url.go b/url.go index 74ef78e..b560e60 100644 --- a/url.go +++ b/url.go @@ -24,30 +24,38 @@ type URLParseResult struct { Parameter map[string]string `json:"parameter"` } -// URLEncode ... +// ownURL ... +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 15:38 2022/5/14 +type ownURL struct { +} + +// Encode ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2:39 下午 2021/11/4 -func URLEncode(inputURL string) string { +func (ou *ownURL) Encode(inputURL string) string { return url.QueryEscape(inputURL) } -// URLDecode ... +// Decode ... // // Author : go_developer@163.com<白茶清欢> // // Date : 2:39 下午 2021/11/4 -func URLDecode(inputURL string) (string, error) { +func (ou *ownURL) Decode(inputURL string) (string, error) { return url.QueryUnescape(inputURL) } -// URLParse url解析 +// Parse url解析 // // Author : go_developer@163.com<白茶清欢> // // Date : 2:39 下午 2021/11/4 -func URLParse(inputURL string) (*URLParseResult, error) { +func (ou *ownURL) Parse(inputURL string) (*URLParseResult, error) { var ( parseResult *url.URL err error @@ -76,7 +84,7 @@ func URLParse(inputURL string) (*URLParseResult, error) { // Author : go_developer@163.com<白茶清欢> // // Date : 2:43 下午 2021/11/4 -func BuildQueryURL(apiURL string, parameter map[string]string) string { +func (ou *ownURL) BuildQueryURL(apiURL string, parameter map[string]string) string { u := url.Values{} for k, v := range parameter { u.Set(k, v)