From ce706afac09233beecc78c6a0dfcdc993f8a6127 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Sat, 14 Jan 2023 18:42:45 +0530 Subject: [PATCH] Add config.new() function for default configuration --- config/config.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/config/config.go b/config/config.go index 5194783..c773fef 100644 --- a/config/config.go +++ b/config/config.go @@ -73,19 +73,8 @@ type Config struct { Theme ThemeConfig `yaml:"theme"` } -func Load() (*Config, error) { - path, err := os.UserConfigDir() - if err != nil { - return nil, err - } - - path = filepath.Join(path, Name) - err = os.MkdirAll(path, os.ModePerm) - if err != nil { - return nil, err - } - - c := Config{ +func new() Config { + return Config{ Mouse: true, Timestamps: false, MessagesLimit: 50, @@ -131,6 +120,21 @@ func Load() (*Config, error) { MessageInput: MessageInputThemeConfig{}, }, } +} + +func Load() (*Config, error) { + path, err := os.UserConfigDir() + if err != nil { + return nil, err + } + + path = filepath.Join(path, Name) + err = os.MkdirAll(path, os.ModePerm) + if err != nil { + return nil, err + } + + c := new() path = filepath.Join(path, "config.yml") _, err = os.Stat(path) if os.IsNotExist(err) {