/
datastruct.go
45 lines (36 loc) · 863 Bytes
/
datastruct.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
package main
import (
"io/ioutil"
"log"
"github.com/BurntSushi/toml"
)
type configData struct {
Base tbase
Requests []tRequests
}
type tbase struct {
URL string
}
type tRequests struct {
URL string
Usebase bool
Method string
Typebody string
Body string
Params map[string]string
}
// Function loadRequests loads the requests data structures
func loadRequests(inFName string) (retErr error) {
var fbytes []byte
// Read the YAML file data into a byte array
fbytes, retErr = ioutil.ReadFile(inFName)
if retErr != nil {
log.Fatalln("Fn loadRequests: Error reading data to initialize Customers see:", retErr)
}
// Unmarshall the YAML data into the data structure
retErr = toml.Unmarshal(fbytes, &cData)
if retErr != nil {
log.Fatalln("Fn loadCustomers: Error parsing the Customer TOML data see:", retErr)
}
return
}