31 lines
846 B
Go
31 lines
846 B
Go
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: */
|