fix: API version and release are get from config file

main
Nilo Roberto C Paim 2023-10-24 18:36:35 -03:00
parent 0d2e37fd13
commit 1df3f1926c
5 changed files with 10 additions and 7 deletions

View File

@ -1,4 +1,5 @@
{
"version": "1.1.0",
"release": [
{
"releasetype": "prod",

View File

@ -8,6 +8,7 @@ import (
)
type Config struct {
Version string
Release []ConfigType
}

View File

@ -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

View File

@ -1,6 +1,6 @@
package globals
var (
API_VERSION = "1.1.0"
API_VERSION = ""
API_RELEASE = ""
)

View File

@ -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)