galdric/readConfig.go
readConfig.goRaw
1package main
2
3import (
4 "encoding/json"
5 "fmt"
6 "io/ioutil"
7)
8
9type Config struct {
10 ImgWidth int `json:"imgWidth"`
11 ImgHeigh int `json:"imgHeigh"`
12}
13
14var config Config
15
16func readConfig(path string) {
17 file, err := ioutil.ReadFile(path)
18 if err != nil {
19 fmt.Println("error: ", err)
20 }
21 content := string(file)
22 json.Unmarshal([]byte(content), &config)
23}