fix: API version and release are get from config file
parent
0d2e37fd13
commit
1df3f1926c
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"version": "1.1.0",
|
||||||
"release": [
|
"release": [
|
||||||
{
|
{
|
||||||
"releasetype": "prod",
|
"releasetype": "prod",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
Version string
|
||||||
Release []ConfigType
|
Release []ConfigType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,10 @@ package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"api/config"
|
"api/config"
|
||||||
"api/globals"
|
|
||||||
"api/models"
|
"api/models"
|
||||||
"api/utils"
|
"api/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
|
|
||||||
|
|
@ -29,8 +27,6 @@ func ConnectDB() error {
|
||||||
return erre
|
return erre
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.API_RELEASE = strings.ToUpper(config.Configurations.ReleaseType)
|
|
||||||
|
|
||||||
driver := config.Configurations.Data.DB_DRIVER
|
driver := config.Configurations.Data.DB_DRIVER
|
||||||
user := config.Configurations.Data.DB_USER
|
user := config.Configurations.Data.DB_USER
|
||||||
password := config.Configurations.Data.DB_PASSWORD
|
password := config.Configurations.Data.DB_PASSWORD
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package globals
|
package globals
|
||||||
|
|
||||||
var (
|
var (
|
||||||
API_VERSION = "1.1.0"
|
API_VERSION = ""
|
||||||
API_RELEASE = ""
|
API_RELEASE = ""
|
||||||
)
|
)
|
||||||
|
|
|
||||||
9
main.go
9
main.go
|
|
@ -9,7 +9,9 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||||
|
|
@ -41,9 +43,12 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globals.API_VERSION = config.Conf.Version
|
||||||
|
globals.API_RELEASE = strings.ToUpper(config.Configurations.ReleaseType)
|
||||||
|
|
||||||
// Starts process
|
// Starts process
|
||||||
log.Println("Starting API", globals.API_VERSION)
|
log.Println("Starting API", globals.API_VERSION+" ("+globals.API_RELEASE+")")
|
||||||
log.Println("OS:", os.Getenv("OS"))
|
log.Println("OS:", runtime.GOOS)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error opening file: %v", err)
|
log.Fatalf("Error opening file: %v", err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue