0

[WIP] MOAR linter fixes, also move init to tg lib

This commit is contained in:
eleksir
2025-11-09 12:25:51 +03:00
parent bb2425f404
commit ddcc8b1c87
12 changed files with 120 additions and 103 deletions

View File

@@ -5,7 +5,6 @@ import (
"fmt"
"os"
"os/signal"
"path/filepath"
"syscall"
"aleesa-telegram-go/internal/log"
@@ -15,48 +14,15 @@ import (
"github.com/go-redis/redis/v8"
)
// init производит некоторую инициализацию перед запуском main().
func init() {
var (
err error
)
executablePath, err := os.Executable()
if err != nil {
log.Fatalf("Unable to get current executable path: %s", err)
}
configJSONPath := filepath.Dir(executablePath) + "/data/config.json"
locations := []string{
"~/.aleesa-telegram-go.json",
"~/aleesa-telegram-go.json",
"/etc/aleesa-telegram-go.json",
configJSONPath,
}
for _, location := range locations {
tg.Config, err = tg.ParseConfig(location)
if err == nil {
break
}
log.Errorf("Unable to parse config at %s: %s", location, err)
}
if err != nil {
os.Exit(1)
}
}
func main() {
var (
logfile *os.File
err error
)
// Найдём и прочитаем конфиг.
tg.ReadConfig()
// Откроем лог и скормим его логгеру.
if tg.Config.Log != "" {
logfile, err = os.OpenFile(tg.Config.Log, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)

View File

@@ -1,4 +1,5 @@
package settingsmigrator
// main Импортирует настройки из файла settings.json в базу с настройками.
package main
import (
"fmt"