2015-07-20 19:45:20 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2015-07-23 21:14:50 +00:00
|
|
|
"io/ioutil"
|
2015-07-20 19:45:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type UserConfig struct {
|
|
|
|
ApplicationId string
|
|
|
|
ApiKey string
|
|
|
|
UserId string
|
|
|
|
Username string
|
|
|
|
DeviceType string
|
|
|
|
Uuid string
|
|
|
|
RegisteredAt float64
|
|
|
|
DeviceId float64
|
|
|
|
}
|
|
|
|
|
|
|
|
func ReadConfig(path string) (UserConfig, error) {
|
|
|
|
|
|
|
|
var config UserConfig
|
|
|
|
|
2015-07-23 21:14:50 +00:00
|
|
|
data, err := ioutil.ReadFile(path)
|
2015-07-20 19:45:20 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return config, err
|
|
|
|
}
|
|
|
|
|
2015-07-23 21:14:50 +00:00
|
|
|
err = json.Unmarshal(data, &config)
|
2015-07-20 19:45:20 +00:00
|
|
|
|
|
|
|
return config, err
|
|
|
|
}
|