-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleNsqTopic.go
More file actions
74 lines (64 loc) · 1.29 KB
/
DeleNsqTopic.go
File metadata and controls
74 lines (64 loc) · 1.29 KB
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
package main
import (
"github.com/parnurzeal/gorequest"
"strings"
"fmt"
"encoding/json"
"errors"
"os"
"bufio"
"io"
)
type Topic struct {
Topics []string `json:"topics"`
Message string `json:"message"`
}
const (
//sit
url1_sit = "http://**:4171/api/topics"
url2_sit = "http://**:4161/topic/delete"
//prod
url1_prod = "http://**:4171/api/topics"
url2_prod = "http://**:4161/topic/delete"
)
func GetTopicList() {
var topic Topic
request := gorequest.New()
resp, body, errs := request.Get(url1_sit).End()
if resp.StatusCode != 200 || len(errs) != 0 {
newError := errors.New("topicsUrl ERROR")
print(newError)
}
json.Unmarshal([]byte(body), &topic)
for _, val := range topic.Topics {
if strings.Contains(val, "kasha") {
fmt.Println(val)
}
}
}
func DeleTopicByFile() {
request := gorequest.New()
fi ,err := os.Open("topic")
if err != nil{
fmt.Println(err.Error())
return
}
defer fi.Close()
br := bufio.NewReader(fi)
for {
a, _, c := br.ReadLine()
if c == io.EOF {
break
}
a1 := string(a)
resp, _, errs := request.Post(url2_prod+"?topic="+a1).End()
if resp.StatusCode != 200 || len(errs) != 0 {
newError := errors.New("topicsUrl ERROR")
print(newError)
}
fmt.Printf("topic %s is already by deleted\n",a1)
}
}
func main() {
DeleTopicByFile()
}