From 61f15ef9e3d7c92094801c71f942a75002c05c68 Mon Sep 17 00:00:00 2001 From: lyx0 <66651385+lyx0@users.noreply.github.com> Date: Sat, 20 Aug 2022 15:14:05 +0200 Subject: [PATCH] move application and config struct to main --- cmd/bot/errors.go | 12 ++++++++++++ cmd/bot/main.go | 20 ++++++++++++++++++++ cmd/bot/models.go | 37 ------------------------------------- 3 files changed, 32 insertions(+), 37 deletions(-) create mode 100644 cmd/bot/errors.go delete mode 100644 cmd/bot/models.go diff --git a/cmd/bot/errors.go b/cmd/bot/errors.go new file mode 100644 index 0000000..6aacc49 --- /dev/null +++ b/cmd/bot/errors.go @@ -0,0 +1,12 @@ +package main + +import ( + "errors" +) + +var ( + ErrUserLevelNotInteger = errors.New("user level must be a number") + ErrCommandLevelNotInteger = errors.New("command level must be a number") + ErrRecordNotFound = errors.New("user not found in the database") + ErrUserInsufficientLevel = errors.New("user has insufficient level") +) diff --git a/cmd/bot/main.go b/cmd/bot/main.go index 37d7c0a..c74a241 100644 --- a/cmd/bot/main.go +++ b/cmd/bot/main.go @@ -16,6 +16,26 @@ import ( "go.uber.org/zap" ) +type config struct { + twitchUsername string + twitchOauth string + commandPrefix string + environment string + db struct { + dsn string + maxOpenConns int + maxIdleConns int + maxIdleTime string + } +} + +type Application struct { + TwitchClient *twitch.Client + Logger *zap.SugaredLogger + Db *sql.DB + Models data.Models +} + func main() { var cfg config diff --git a/cmd/bot/models.go b/cmd/bot/models.go deleted file mode 100644 index 975f6a0..0000000 --- a/cmd/bot/models.go +++ /dev/null @@ -1,37 +0,0 @@ -package main - -import ( - "database/sql" - "errors" - - "github.com/gempir/go-twitch-irc/v3" - "github.com/lyx0/nourybot/internal/data" - "go.uber.org/zap" -) - -var ( - ErrUserLevelNotInteger = errors.New("user level must be a number") - ErrCommandLevelNotInteger = errors.New("command level must be a number") - ErrRecordNotFound = errors.New("user not found in the database") - ErrUserInsufficientLevel = errors.New("user has insufficient level") -) - -type config struct { - twitchUsername string - twitchOauth string - commandPrefix string - environment string - db struct { - dsn string - maxOpenConns int - maxIdleConns int - maxIdleTime string - } -} - -type Application struct { - TwitchClient *twitch.Client - Logger *zap.SugaredLogger - Db *sql.DB - Models data.Models -}