From 15e81cf2eaacf5bbf0793227fad6289bd92bb261 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Fri, 13 Sep 2024 00:15:56 +0200 Subject: [PATCH] using parameter to determine config name/path --- util/config.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/config.go b/util/config.go index 94a6997..1c2f3be 100644 --- a/util/config.go +++ b/util/config.go @@ -6,7 +6,7 @@ import ( "os" ) -func ReadConfigs() ([]*Config, error) { +func ReadConfigs(name string) ([]*Config, error) { file, err := os.Open("configs.json") if err != nil { @@ -25,8 +25,8 @@ func ReadConfigs() ([]*Config, error) { return config, nil } -func SaveConfig(config Config) error { - configs, _ := ReadConfigs() +func SaveConfig(name string, config Config) error { + configs, _ := ReadConfigs(name) configs = append(configs, &config) data, err := json.Marshal(configs) @@ -34,6 +34,6 @@ func SaveConfig(config Config) error { return err } - err = os.WriteFile("configs.json", data, 0666) + err = os.WriteFile(name, data, 0666) return err }