master
李光春 2 years ago
parent e1ccdce4d4
commit 55fabac5cc

@ -1,8 +1,9 @@
workspace:
base: /go
path: src/golang/library
pipeline:
test:
kind: pipeline
type: docker
name: clone
steps:
- name: test-golang
image: golang:1.18
commands:
- go env -w GO111MODULE=on

1
.gitignore vendored

@ -4,6 +4,5 @@
.idea
.vscode
*.log
*_test.go
gomod.sh
/vendor/

@ -0,0 +1,26 @@
package gorequest
import (
"testing"
)
func TestGet(t *testing.T) {
appHttp := NewHttp()
appHttp.SetDebug()
//appHttp.SetUri("https://api.dtapp.net/ip")
get, err := appHttp.Get("https://api.dtapp.net/ip")
t.Logf("get%+v\n", get)
t.Logf("get.ResponseBody%s\n", get.ResponseBody)
t.Logf("err%s\n", err)
}
func TestPost(t *testing.T) {
appHttp := NewHttp()
appHttp.SetUri("https://api.dtapp.net/ip")
get, err := appHttp.Post()
t.Logf("get%+v\n", get)
t.Logf("get.ResponseBody%s\n", get.ResponseBody)
t.Logf("err%s\n", err)
}

@ -0,0 +1,19 @@
package gorequest
import (
"log"
"testing"
)
func TestParams(t *testing.T) {
params1 := NewParams()
params2 := NewParams()
params1.Set("a", "1")
params2.Set("b", "2")
params3 := NewParamsWith(params1, params2)
log.Println(params1.DeepCopy())
log.Println(params2.DeepCopy())
log.Println(params3.DeepCopy())
log.Println(params1.DeepCopy())
log.Println(params2.DeepCopy())
}

@ -0,0 +1,12 @@
package gorequest
import "testing"
func TestUrlParse(t *testing.T) {
t.Logf("%+v", UriParse("https://api.dtapp.net/ip?ip=127.0.0.1#history"))
t.Logf("%+v", UriParse("https://test:abcd123@golangbyexample.com:8000/tutorials/intro?type=advance&compact=false#history"))
t.Logf("%+v", UriFilterExcludeQueryString("/"))
t.Logf("%+v", UriFilterExcludeQueryString("/favicon.ico"))
t.Logf("%+v", UriFilterExcludeQueryString("/ip"))
t.Logf("%+v", UriFilterExcludeQueryString("/ip?ip=127.0.0.1"))
}

@ -0,0 +1,15 @@
package gorequest
import "testing"
func TestGetRandomUserAgentSystem(t *testing.T) {
t.Log(GetRandomUserAgentSystem())
}
func TestGetRandomUserAgent(t *testing.T) {
t.Log(GetRandomUserAgent())
}
func TestDtaUa(t *testing.T) {
t.Log(DtaUa())
}
Loading…
Cancel
Save