Do not repeat code whenever possible

Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
2025-12-30 07:53:26 -03:00
parent 811028bebc
commit 60688d7a0e
3 changed files with 22 additions and 18 deletions

View File

@@ -1,6 +1,8 @@
package mikuru
import (
"log"
"os"
"gopkg.in/ini.v1"
)
@@ -9,6 +11,16 @@ var Config struct {
Token string
}
func ConfInit() {
config, err := os.UserConfigDir()
if err != nil {
log.Println("Unable to obtain user's configuration directory")
log.Fatal(err)
}
configPath := config + "/mikuru.ini"
Parse(configPath)
}
func Parse(file string) error {
cfg, err := ini.Load(file)
if err != nil {