-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_model.go
45 lines (39 loc) · 1.03 KB
/
config_model.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 (
"encoding/json"
"fmt"
"image"
)
type Config struct {
Filepath string `json:"filepath"`
Names []string `json:"names"`
NumRows int `json:"numRows"`
NumColumns int `json:"numColumns"`
NextRectOrigin image.Point `json:"nextRectOrigin"`
Seed int64 `json:"seedInteger"`
Test bool `json:"testing"`
FirstRect struct {
Origin image.Point `json:"origin"`
OppositeCorner image.Point `json:"oppositeCorner"`
} `json:"firstRect"`
ExtraSquares []ExtraSquare `json:"extraSquares"`
}
type ExtraSquare struct {
Filepath string `json:"filepath"`
NumOfSquares int `json:"numOfSquares"`
}
func testConfig() Config {
test := Config{}
//add test data
return test
}
func parseConfig(jsonStr string) Config {
var newConfig Config
newConfig.ExtraSquares = []ExtraSquare{}
err := json.Unmarshal([]byte(jsonStr), &newConfig)
if err != nil {
fmt.Println("ERROR UNMARSHALLING")
panic(err.Error())
}
return newConfig
}