From 1df3f1926c497af5b0689cf171d5dd4caae10388 Mon Sep 17 00:00:00 2001 From: Nilo Roberto C Paim Date: Tue, 24 Oct 2023 18:36:35 -0300 Subject: [PATCH] fix: API version and release are get from config file --- config.json | 1 + config/config.go | 1 + database/database.go | 4 ---- globals/globals.go | 2 +- main.go | 9 +++++++-- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/config.json b/config.json index 1383222..39f7e8f 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,5 @@ { + "version": "1.1.0", "release": [ { "releasetype": "prod", diff --git a/config/config.go b/config/config.go index bc09df6..61af956 100644 --- a/config/config.go +++ b/config/config.go @@ -8,6 +8,7 @@ import ( ) type Config struct { + Version string Release []ConfigType } diff --git a/database/database.go b/database/database.go index 1531210..aeeaabb 100644 --- a/database/database.go +++ b/database/database.go @@ -2,12 +2,10 @@ package database import ( "api/config" - "api/globals" "api/models" "api/utils" "fmt" "log" - "strings" "github.com/joho/godotenv" @@ -29,8 +27,6 @@ func ConnectDB() error { return erre } - globals.API_RELEASE = strings.ToUpper(config.Configurations.ReleaseType) - driver := config.Configurations.Data.DB_DRIVER user := config.Configurations.Data.DB_USER password := config.Configurations.Data.DB_PASSWORD diff --git a/globals/globals.go b/globals/globals.go index b0888fc..cc99ff1 100644 --- a/globals/globals.go +++ b/globals/globals.go @@ -1,6 +1,6 @@ package globals var ( - API_VERSION = "1.1.0" + API_VERSION = "" API_RELEASE = "" ) diff --git a/main.go b/main.go index 7b0b212..477d4a9 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,9 @@ import ( "io" "log" "os" + "runtime" "strconv" + "strings" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/cors" @@ -41,9 +43,12 @@ func main() { return } + globals.API_VERSION = config.Conf.Version + globals.API_RELEASE = strings.ToUpper(config.Configurations.ReleaseType) + // Starts process - log.Println("Starting API", globals.API_VERSION) - log.Println("OS:", os.Getenv("OS")) + log.Println("Starting API", globals.API_VERSION+" ("+globals.API_RELEASE+")") + log.Println("OS:", runtime.GOOS) if err != nil { log.Fatalf("Error opening file: %v", err)