feat: follow XDG convention for configuration file (#123)
This commit is contained in:
parent
92c3be341c
commit
7dd1b0eb64
2 changed files with 8 additions and 2 deletions
|
|
@ -72,7 +72,7 @@ sudo mv ./discordo /usr/local/bin
|
|||
|
||||
### Configuration
|
||||
|
||||
A default configuration file is created on first start-up at `$HOME/.config/discordo.toml` on Unix, `$HOME/Library/Application Support/discordo.toml` on Darwin, and `%AppData%/discordo.toml` on Windows.
|
||||
A default configuration file is created on first start-up at `$HOME/.config/discordo/config.toml` on Unix, `$HOME/Library/Application Support/discordo/config.toml` on Darwin, and `%AppData%/discordo/config.toml` on Windows.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package util
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
|
@ -37,8 +38,13 @@ func LoadConfig() Config {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
configPath += "/discordo/config.toml"
|
||||
// Create a directory as well as create all of the nested directories, recursively.
|
||||
err = os.MkdirAll(filepath.Dir(configPath), os.ModePerm)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
configPath += "/discordo.toml"
|
||||
c := Config{}
|
||||
// If the configuration file does not exist, create and write the default configuration to the file.
|
||||
if _, err = os.Stat(configPath); os.IsNotExist(err) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue