From a1f1a258bbff55b26cce5f50c5641ed1d2ef7cab Mon Sep 17 00:00:00 2001 From: ayntgl Date: Thu, 14 Oct 2021 15:48:14 +0400 Subject: [PATCH] Use OS-specific config directory to store config file --- README.md | 2 +- config.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1e68835..1ad11ce 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ sudo mv ./discordo /usr/local/bin ## Usage -1. Run the `discordo` executable with no arguments. A new and default configuration will be created at `~/.config/discordo.toml` on first startup. +1. Run the `discordo` executable with no arguments. On first startup, a default configuration file will be created at `$HOME/.config/discordo.toml` on Unix, `%AppData%/discordo.toml` on Windows, `$HOME/Library/Application Support/discordo.toml` on Darwin, and `$home/lib/discordo.toml` on Plan 9. 2. Log in using the account email and password (first-time login) and click on the "Login" button to continue. > By default, Discordo utilizes OS-specific keyring to store credentials such as client authentication token. However, if you prefer not to use a keyring (not recommended), you may set the `token` field in the configuration file and Discordo will prioritize the usage of the provided token to login instead of keyring. diff --git a/config.go b/config.go index f211552..f0a2e23 100644 --- a/config.go +++ b/config.go @@ -77,12 +77,12 @@ type config struct { } func loadConfig() *config { - u, err := os.UserHomeDir() + configPath, err := os.UserConfigDir() if err != nil { panic(err) } - configPath := u + "/.config/discordo.toml" + configPath = configPath + "/discordo.toml" if _, err = os.Stat(configPath); os.IsNotExist(err) { f, err := os.Create(configPath) if err != nil {