-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfig.go
47 lines (37 loc) · 945 Bytes
/
config.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
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
func config_handling(action string) error {
var err error
var json_data []byte
if action == "load" {
config_data, err := ioutil.ReadFile(configFile)
if err != nil{
logger("error", "[Error]", err, err, 1)
}
err = json.Unmarshal(config_data, &data)
if err != nil{
logger("error", "[Error]", err, err, 1)
}
} else if action == "save" {
json_data, err = json.MarshalIndent(data, "", " ")
ioutil.WriteFile(configFile, json_data, 0644)
Execute_command("cd " + data.Config.Directory_work + ";git add .")
}
return err
}
//this for setup the config file and folder result and work directory
func setupFirst() {
if data.Config.Is_first == true {
Execute_command(fmt.Sprintf("mkdir %s;mkdir %s;cd %s;git init",
data.Config.Directory_result,
data.Config.Directory_work,
data.Config.Directory_work,
),
)
data.Config.Is_first = false
}
}