-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
100 lines (83 loc) · 1.74 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package main
import (
"fmt"
"github.com/tidwall/gjson"
"github.com/xuri/excelize/v2"
"io"
"log"
"net/http"
)
func main() {
// 打开 Excel 文件
f, err := excelize.OpenFile("123.xlsx")
if err != nil {
fmt.Println(err)
return
}
// 获取第一个 sheet 并读取数据
rows, err := f.GetRows("Sheet1")
if err != nil {
fmt.Println(err)
return
}
req, err := http.NewRequest("GET", "http://localhost:8080/query", nil)
if err != nil {
fmt.Print(12345)
}
query := req.URL.Query()
// 遍历每一行数据
for i, row := range rows {
if i == 0 { // 跳过表头
continue
}
name123 := row[4]
result2 := gjson.Parse(name123)
// 获取result2的的key和
result2.ForEach(func(key, value gjson.Result) bool {
query.Add(key.String(), value.String())
return true
})
}
req.URL.RawQuery = query.Encode()
// 发起 HTTP 请求
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Printf("123")
}
defer resp.Body.Close()
// // 3. 处理响应
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
}
}(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Print(string(body), "\n")
}
//func main() {
// req, err := http.NewRequest("GET", "http://localhost:8080/query", nil)
// if err != nil {
// fmt.Print(12345)
// }
//
// query := req.URL.Query()
// query.Add("name", "xiaming")
// req.URL.RawQuery = query.Encode()
//
// resp, err := http.DefaultClient.Do(req)
// if err != nil {
// fmt.Print(1234567)
// }
//
// var heightResp HeightResponse
// err = json.NewDecoder(resp.Body).Decode(&heightResp)
// if err != nil {
// fmt.Print(12345678)
// }
//
// fmt.Print(heightResp.Height)
//}
git remote add origin https://gitee.com/huangyingjie6/pandas.git