1
0
mirror of https://github.com/taigrr/godns synced 2025-01-18 04:03:25 -08:00
godns/settings.go
2014-05-12 13:04:29 +08:00

35 lines
537 B
Go

package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)
const config_path string = "config.json"
type Settings struct {
Email string
Password string
Domain string
Sub_domain string
IP_Url string
}
func LoadSettings() Settings {
file, err := ioutil.ReadFile(config_path)
if err != nil {
fmt.Println("Error occurs while reading config file, please make sure config file exists!")
os.Exit(1)
}
var setting Settings
json.Unmarshal(file, &setting)
fmt.Println(setting.Email)
return setting
}