arnaucube
arnaucube/konstruiPublic Self-hosted repository
konstrui/readTimmyConfig.go
readTimmyConfig.goRaw
 1package main
 2
 3import (
 4	"encoding/json"
 5	"fmt"
 6	"io/ioutil"
 7)
 8
 9//TimmyConfig is the configuration from the file timmyConfig.json, on the folder /webInput
10type TimmyConfig struct {
11	Title   string   `json:"title"`
12	Author  string   `json:"author"`
13	Github  string   `json:"github"`
14	Website string   `json:"website"`
15	Files   []string `json:"files"`
16}
17
18var timmyConfig TimmyConfig
19
20func readTimmyConfig(path string) {
21	file, e := ioutil.ReadFile(path)
22	if e != nil {
23		fmt.Println("error:", e)
24	}
25	content := string(file)
26	json.Unmarshal([]byte(content), &timmyConfig)
27}