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