konstrui/readKonstruiConfig.go
readKonstruiConfig.goRaw
1package main
2
3import (
4 "encoding/json"
5 "fmt"
6 "io/ioutil"
7)
8
9//RepeatPages is from the json config, is an array inside KonstruiConfig
10type RepeatPages struct {
11 HtmlPage string `json:"htmlPage"`
12 Data string `json:"data"`
13}
14
15//KonstruiConfig is the configuration from the file konstruiConfig.json, on the folder /webInput
16type KonstruiConfig struct {
17 Title string `json:"title"`
18 Author string `json:"author"`
19 Github string `json:"github"`
20 Website string `json:"website"`
21 Files []string `json:"files"`
22 RepeatPages []RepeatPages
23 CopyRaw []string `json:"copyRaw"`
24}
25
26var konstruiConfig KonstruiConfig
27
28func readKonstruiConfig(path string) {
29 file, e := ioutil.ReadFile(path)
30 if e != nil {
31 fmt.Println("error:", e)
32 }
33 content := string(file)
34 json.Unmarshal([]byte(content), &konstruiConfig)
35}