You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
965 B
Go

package main
import (
"fmt"
"log"
"git.sp4ke.xyz/AnisB/shelf_api_go/config"
"github.com/gin-gonic/gin"
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
)
var (
server *gin.Engine
db *sqlx.DB
)
func main() {
config, err := config.LoadConfig(".")
if err != nil {
log.Fatalf("could not load config: %v", err)
}
fmt.Printf("%T\n", config)
db, err := sqlx.Open(config.PostgreDriver, config.PostgresSource)
if err != nil {
log.Fatalf("could not connect to database: %v", err)
}
err = db.Ping()
fmt.Printf("Ping: %v\n", db.Ping())
if err != nil {
log.Fatalf("could not ping database: %v", err)
}
r := gin.Default()
if err := r.Run(":5000"); err != nil {
panic(err.Error())
}
/*router := server.Group("/api")
router.GET("/healthchecker", func(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{"status": "success", "message": "Welcome to Golang with PostgreSQL"})
})
log.Fatal(server.Run(":" + config.PostgresPort))*/
}