blogo/readConfig.go
readConfig.goRaw
1package main
2
3import (
4 "encoding/json"
5 "io/ioutil"
6)
7
8//Post is the struct for each post of the blog
9type Post struct {
10 Thumb string `json:"thumb"`
11 Md string `json:"md"`
12}
13
14//Config gets the config.json file into struct
15type Config struct {
16 Title string `json:"title"`
17 IndexTemplate string `json:"indexTemplate"`
18 PostThumbTemplate string `json:"postThumbTemplate"`
19 Posts []Post `json:"posts"`
20 CopyRaw []string `json:"copyRaw"`
21}
22
23var config Config
24
25func readConfig(path string) {
26 file, err := ioutil.ReadFile(path)
27 check(err)
28 content := string(file)
29 json.Unmarshal([]byte(content), &config)
30}