61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
|
// Package util...
|
||
|
//
|
||
|
// Description : util...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 2021-11-04 2:58 下午
|
||
|
package util
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
// TestBuildQueryURL ...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 3:04 下午 2021/11/4
|
||
|
func TestBuildQueryURL(t *testing.T) {
|
||
|
url := "https://ww.baidu.com/api/detail"
|
||
|
parameter := map[string]string{
|
||
|
"name": "zhang",
|
||
|
"age": "18",
|
||
|
}
|
||
|
fmt.Println(BuildQueryURL(url, parameter))
|
||
|
url = "https://ww.baidu.com/api/detail?tag=1"
|
||
|
fmt.Println(BuildQueryURL(url, parameter))
|
||
|
}
|
||
|
|
||
|
// TestURLDecode ...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 3:04 下午 2021/11/4
|
||
|
func TestURLDecode(t *testing.T) {
|
||
|
|
||
|
}
|
||
|
|
||
|
// TestURLEncode ...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 3:05 下午 2021/11/4
|
||
|
func TestURLEncode(t *testing.T) {
|
||
|
|
||
|
}
|
||
|
|
||
|
// TestURLParse 测试URL解析
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 3:00 下午 2021/11/4
|
||
|
func TestURLParse(t *testing.T) {
|
||
|
inputURL := "https://www.baidu.com/api/detail?a=1&b=2&a=3&d=qwe"
|
||
|
r, _ := URLParse(inputURL)
|
||
|
byteData, _ := json.Marshal(r)
|
||
|
fmt.Println(string(byteData))
|
||
|
}
|