39 lines
1 KiB
Go
39 lines
1 KiB
Go
package config
|
|
|
|
import (
|
|
"github.com/BurntSushi/toml"
|
|
"github.com/kirsle/configdir"
|
|
"path/filepath"
|
|
)
|
|
|
|
type Config struct {
|
|
Domain string `toml:"domain"`
|
|
Username string `toml:"username"`
|
|
Password string `toml:"admin_password"`
|
|
Name string `toml:"name"`
|
|
Summary string `toml:"summary"`
|
|
Https bool `toml:"https"`
|
|
IconUrl string `toml:"icon_url""`
|
|
ImageUrl string `toml:"image_url"`
|
|
Secret string `toml:"secret"`
|
|
TrustedHosts []string `toml:"trusted_hosts"`
|
|
ManuallyApproveFollers bool `toml:"manually_approves_followers"`
|
|
}
|
|
|
|
var config Config
|
|
|
|
func init() {
|
|
configPath := configdir.LocalConfig("gopub")
|
|
if err := configdir.MakePath(configPath); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
configFile := filepath.Join(configPath, "profile.toml")
|
|
if _, err := toml.DecodeFile(configFile, &config); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func GetConfig() Config {
|
|
return config
|
|
}
|