-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (32 loc) · 956 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"fmt"
"playground/database"
_ "playground/docs" // swagger docs generated by Swag CLI
"playground/models"
"playground/routing"
"github.com/jinzhu/gorm"
)
//Star Trek API's use a MySQL database to perform CRUD operations
//If you don't have a MySQL instance and still want to use the other API's
//Just change this flag to false
const useMysqlDb = true
// @title Go Web API Playground
// @version 1.0
// @description This is a playground Web API using Gin framework.
// @BasePath /api/v1
func main() {
if useMysqlDb {
//Database Configurations
var err error
database.DB, err = gorm.Open("mysql", database.URL(database.BuildDBConfig()))
if err != nil {
fmt.Println("statuse: ", err)
}
defer database.DB.Close()
database.DB.AutoMigrate(&models.CrewMember{})
}
//Swagger and Routing configuration
r := routing.SetupRouter()
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}