From 7a4249f6dc46e1605b8bb51530e05b62eedb5045 Mon Sep 17 00:00:00 2001 From: Su Yang Date: Fri, 5 Jan 2024 23:11:41 +0800 Subject: [PATCH] chore: split internal/server --- cmd/cmd.go | 5 +++-- cmd/daemon.go => internal/server/server.go | 4 ++-- main.go | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) rename cmd/daemon.go => internal/server/server.go (98%) diff --git a/cmd/cmd.go b/cmd/cmd.go index dc51973..51a93b4 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -4,11 +4,12 @@ import ( "log/slog" FlareData "github.com/soulteary/flare/config/data" + FlareModel "github.com/soulteary/flare/config/model" FlareState "github.com/soulteary/flare/config/state" FlareLogger "github.com/soulteary/flare/internal/logger" ) -func Parse() { +func Parse() FlareModel.Flags { envs := ParseEnvFile(ParseEnvVars()) flags := parseCLI(envs) @@ -36,5 +37,5 @@ func Parse() { } FlareState.AppFlags = flags - startDaemon(&flags) + return flags } diff --git a/cmd/daemon.go b/internal/server/server.go similarity index 98% rename from cmd/daemon.go rename to internal/server/server.go index 1475fd5..11696b1 100644 --- a/cmd/daemon.go +++ b/internal/server/server.go @@ -1,4 +1,4 @@ -package cmd +package FlareServer import ( "context" @@ -36,7 +36,7 @@ import ( FlareWeather "github.com/soulteary/flare/internal/settings/weather" ) -func startDaemon(AppFlags *FlareModel.Flags) { +func StartDaemon(AppFlags *FlareModel.Flags) { if !AppFlags.DebugMode { gin.SetMode(gin.ReleaseMode) diff --git a/main.go b/main.go index f5c53bf..a073f3b 100644 --- a/main.go +++ b/main.go @@ -2,8 +2,10 @@ package main import ( "github.com/soulteary/flare/cmd" + FlareServer "github.com/soulteary/flare/internal/server" ) func main() { - cmd.Parse() + flags := cmd.Parse() + FlareServer.StartDaemon(&flags) }