refactor: rename NewConfig to LoadConfig

This commit is contained in:
ayntgl 2021-11-29 20:10:37 +04:00
parent 7fab952886
commit 4ac65d3cd7
2 changed files with 4 additions and 3 deletions

View file

@ -23,7 +23,7 @@ var (
)
func main() {
conf = util.NewConfig()
conf = util.LoadConfig()
tview.Borders.Horizontal = conf.Borders.Horizontal
tview.Borders.Vertical = conf.Borders.Vertical

View file

@ -64,14 +64,15 @@ type Config struct {
Borders borders `toml:"borders"`
}
// NewConfig loads the configuration file, if the configuration file exists or creates a new one if not, and returns it.
func NewConfig() *Config {
// LoadConfig loads the configuration file, if the configuration file exists or creates a new one if not, and returns it.
func LoadConfig() *Config {
configPath, err := os.UserConfigDir()
if err != nil {
panic(err)
}
configPath += "/discordo.toml"
var c Config
if _, err = os.Stat(configPath); os.IsNotExist(err) {
f, err := os.Create(configPath)