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 MetaImg string `json:"metaimg"`
13 MetaDescr string `json:"metadescr"`
14}
15
16//Config gets the config.json file into struct
17type Config struct {
18 Title string `json:"title"`
19 RelativePath string `json:"relativePath"`
20 AbsoluteUrl string `json:"absoluteUrl"`
21 IndexTemplate string `json:"indexTemplate"`
22 PostThumbTemplate string `json:"postThumbTemplate"`
23 Posts []Post `json:"posts"`
24 CopyRaw []string `json:"copyRaw"`
25}
26
27var config Config
28
29func readConfig(path string) {
30 file, err := ioutil.ReadFile(path)
31 check(err)
32 content := string(file)
33 json.Unmarshal([]byte(content), &config)
34}