Do not repeat code whenever possible
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
12
config.go
12
config.go
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user