Преглед на файлове

Use OS-specific config directory to store config file

ayntgl преди 4 години
родител
ревизия
a1f1a258bb
променени са 2 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. 1 1
      README.md
  2. 2 2
      config.go

+ 1 - 1
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.

+ 2 - 2
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 {