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