-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (45 loc) · 1.08 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
package main
import (
"bufio"
"encoding/csv"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"github.com/MAYLEAF/Sommelier/client"
"github.com/MAYLEAF/Sommelier/logger"
"github.com/MAYLEAF/Sommelier/thread"
)
var request = flag.String("request", "request.json", "<file_name>.json")
var value = flag.String("value", "value.csv", "<file_name>.csv")
func main() {
flag.Parse()
thread.Actions = readJson(*request)
threadList := readCsv(*value)
defer logger.Logger().Close()
TestClient := client.New()
TestClient.CreateThreads(threadList)
TestClient.Test()
}
func readJson(file_name string) map[string]interface{} {
jsonFile, err := os.Open(file_name)
if err != nil {
fmt.Println(err)
}
defer jsonFile.Close()
var result map[string]interface{}
byteValue, _ := ioutil.ReadAll(jsonFile)
json.Unmarshal([]byte(byteValue), &result)
return result
}
func readCsv(file_name string) [][]string {
file, err := os.Open(file_name)
if err != nil {
fmt.Println(err)
}
defer file.Close()
reader := csv.NewReader(bufio.NewReader(file))
csv, _ := reader.ReadAll()
return csv
}