Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.

Commit 169501a

Browse files
committed
优化代码
1 parent f07118d commit 169501a

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
)
99

1010
require (
11-
github.com/json-iterator/go v1.1.6 // indirect
11+
github.com/json-iterator/go v1.1.12 // indirect
1212
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
13-
github.com/modern-go/reflect2 v1.0.1 // indirect
13+
github.com/modern-go/reflect2 v1.0.2 // indirect
1414
)

go.sum

+6
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
4141
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
4242
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
4343
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
44+
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
4445
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
4546
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
4647
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
@@ -71,6 +72,8 @@ github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj
7172
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
7273
github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=
7374
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
75+
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
76+
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
7477
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
7578
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
7679
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
@@ -96,10 +99,13 @@ github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS4
9699
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
97100
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
98101
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
102+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
99103
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
100104
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
101105
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
102106
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
107+
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
108+
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
103109
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
104110
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
105111
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=

src/apis/api.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: ph4nt0mer
33
* @Date: 2022-09-01 15:36:10
44
* @LastEditors: rootphantomer
5-
* @LastEditTime: 2022-09-07 12:03:53
5+
* @LastEditTime: 2022-09-07 15:39:06
66
* @FilePath: /quake_go/src/apis/api.go
77
* @Description:
88
*
@@ -48,9 +48,8 @@ func SearchServicePost(reqjson Reqjson, token string) {
4848
if err != nil {
4949
panic(err)
5050
}
51-
payload := string(datajson)
52-
fmt.Println(payload)
53-
body := tools.ApisPost(setting.URL+uri, payload, token)
51+
fmt.Println(string(datajson))
52+
body := tools.ApisPost(setting.URL+uri, datajson, token)
5453
resut := utils.SeriveLoadJson(body)
5554
data := resut.Data
5655
fields := strings.Split(reqjson.Field, ",")
@@ -70,7 +69,7 @@ func SearchServicePost(reqjson Reqjson, token string) {
7069
// }
7170

7271
}
73-
func ScrollServicePost(query string, start string, size string, token string) {
72+
func ScrollServicePost(query []byte, start string, size string, token string) {
7473
// 服务数据深度查询接口
7574
// curl -X POST "https://quake.360.cn/api/v3/scroll/quake_service" -H "X-QuakeToken: d17140ae-xxxx-xxx-xxxx-c0818b2bbxxx" -H "Content-Type: application/json" -d '{
7675
// "query": "service: http",
@@ -88,7 +87,7 @@ func AggregationServiceGet(token string) {
8887
uri := "/aggregation/quake_service"
8988
tools.ApisGet(setting.URL+uri, token)
9089
}
91-
func AggregationServicePost(query string, start string, size string, token string) {
90+
func AggregationServicePost(query []byte, start string, size string, token string) {
9291
// 获取聚合数据筛选字段
9392
// curl -X GET "https://quake.360.cn/api/v3/aggregation/quake_service" -H "X-QuakeToken: d17140ae-xxxx-xxx-xxxx-c0818b2bbxxx"
9493
uri := "/aggregation/quake_service"

src/tools/commond.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: ph4nt0mer
33
* @Date: 2022-09-01 10:49:31
44
* @LastEditors: rootphantomer
5-
* @LastEditTime: 2022-09-06 18:12:57
5+
* @LastEditTime: 2022-09-07 15:36:09
66
* @FilePath: /quake_go/src/tools/commond.go
77
* @Description:
88
*
@@ -18,10 +18,9 @@ import (
1818
"strings"
1919
)
2020

21-
func ApisPost(url string, data string, token string) string {
22-
var jsonStr = []byte(data)
21+
func ApisPost(url string, data []byte, token string) string {
2322
client := &http.Client{}
24-
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
23+
req, err := http.NewRequest("POST", url, bytes.NewBuffer(data))
2524
if err != nil {
2625
fmt.Println(err)
2726
return err.Error()

0 commit comments

Comments
 (0)