diff --git a/.drone.yml b/.drone.yml index 511f0fc..c56c479 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,9 +3,15 @@ type: docker name: clone steps: - - name: test-golang + - name: Test image: golang:1.18 commands: - go env -w GO111MODULE=on - go env -w GOPROXY=https://goproxy.cn,direct - - go test -v ./... \ No newline at end of file + - go test -v ./... + - name: Benchmark + image: golang:1.18 + commands: + - go env -w GO111MODULE=on + - go env -w GOPROXY=https://goproxy.cn,direct + - go test -bench=. -benchmem \ No newline at end of file diff --git a/http.go b/http.go index dac32e8..096b655 100644 --- a/http.go +++ b/http.go @@ -16,8 +16,6 @@ import ( "time" ) -const Version = "1.0.18" - var userAgentFormat = "DtApp-Request/%s (%s) GO/%s" // Response 返回内容 diff --git a/url.go b/url.go index fd3298b..0d3ad79 100644 --- a/url.go +++ b/url.go @@ -45,3 +45,26 @@ func UriFilterExcludeQueryString(uri string) string { clearUri = strings.TrimRight(clearUri, "?") return strings.TrimRight(clearUri, "/") } + +// LenCode 编码 +func LenCode(s string) string { + escape := url.QueryEscape(s) + return escape +} + +// DeCode 解码 +func DeCode(s string) string { + unescape, _ := url.QueryUnescape(s) + return unescape +} + +// ParseQuery 获取URL参数 https://studygolang.com/articles/2876 +func ParseQuery(s string) map[string][]string { + u, err := url.Parse(s) + if err != nil { + return nil + } + urlParam := u.RawQuery + m, _ := url.ParseQuery(urlParam) + return m +} diff --git a/version.go b/version.go new file mode 100644 index 0000000..5cfb419 --- /dev/null +++ b/version.go @@ -0,0 +1,3 @@ +package gorequest + +const Version = "1.0.19" diff --git a/version_test.go b/version_test.go new file mode 100644 index 0000000..1ecce91 --- /dev/null +++ b/version_test.go @@ -0,0 +1,7 @@ +package gorequest + +import "testing" + +func TestVersion(t *testing.T) { + t.Log(Version) +}