From 222a1c09f010c11e4ff2055b9a1f3cf8a70eeb78 Mon Sep 17 00:00:00 2001 From: ayntgl Date: Fri, 24 Sep 2021 14:08:58 +0400 Subject: [PATCH] Merge config package into main --- util/config.go => config.go | 12 +++++------- main.go | 5 ++--- 2 files changed, 7 insertions(+), 10 deletions(-) rename util/config.go => config.go (85%) diff --git a/util/config.go b/config.go similarity index 85% rename from util/config.go rename to config.go index af45e16..7eb1d25 100644 --- a/util/config.go +++ b/config.go @@ -1,4 +1,4 @@ -package util +package main import ( "encoding/json" @@ -21,8 +21,7 @@ type keybindings struct { MessageInputFieldFocus string } -// Config consists of fields that can be customized by the user using the configuration file. -type Config struct { +type config struct { Token string Mouse bool Notifications bool @@ -32,8 +31,7 @@ type Config struct { Keybindings keybindings } -// LoadConfig createsa new configuration file (if does not exist) and returns the default configuration or reads the existing configuration file from the default path. -func LoadConfig() *Config { +func loadConfig() *config { u, err := os.UserHomeDir() if err != nil { panic(err) @@ -52,7 +50,7 @@ func LoadConfig() *Config { } defer f.Close() - c := Config{ + c := config{ Mouse: true, Notifications: true, UserAgent: "" + @@ -95,7 +93,7 @@ func LoadConfig() *Config { panic(err) } - var c Config + var c config if err = json.Unmarshal(d, &c); err != nil { panic(err) } diff --git a/main.go b/main.go index c7213e4..d752581 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "github.com/ayntgl/discordgo" "github.com/gdamore/tcell/v2" - "github.com/rigormorrtiss/discordo/util" "github.com/rivo/tview" "github.com/zalando/go-keyring" ) @@ -18,14 +17,14 @@ var ( messageInputField *tview.InputField mainFlex *tview.Flex - conf *util.Config + conf *config session *discordgo.Session selectedChannel *discordgo.Channel selectedMessage *discordgo.Message ) func main() { - conf = util.LoadConfig() + conf = loadConfig() tview.Styles = conf.Theme app = tview.NewApplication()