Initial commit
This commit is contained in:
30
internal/holy/configLocations.go
Normal file
30
internal/holy/configLocations.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package holy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// defaultConfigFileLocations выдаёт варианты путей, по которым может находиться конфиг-файл.
|
||||
func defaultConfigFileLocations() ([]string, error) {
|
||||
var locations []string
|
||||
|
||||
executablePath, err := os.Executable()
|
||||
|
||||
if err != nil {
|
||||
return locations, fmt.Errorf("Unable to get my executable path: %w", err) //nolint: staticcheck // Looks like golangci-lint ignoring settings about fucking ST1005 check. We want readable errors despite what wants author of linter or assholes from go dev team.
|
||||
}
|
||||
|
||||
configJSONPath := filepath.Dir(executablePath) + "/data/config.json"
|
||||
|
||||
locations = []string{
|
||||
"~/.tg-holy-bot.json",
|
||||
"/etc/tg-holy-bot.json",
|
||||
configJSONPath,
|
||||
}
|
||||
|
||||
return locations, nil
|
||||
}
|
||||
|
||||
/* vim: set ft=go noet ai ts=4 sw=4 sts=4: */
|
||||
Reference in New Issue
Block a user