diff --git a/get_started.md b/get_started.md index c28c999..574626b 100644 --- a/get_started.md +++ b/get_started.md @@ -8,47 +8,49 @@ First, create a `main.go` with package main import ( - "fmt" - "net/http" - "github.com/qor/qor" - "github.com/qor/admin" - "github.com/jinzhu/gorm" - _ "github.com/jinzhu/gorm/dialects/sqlite" + "fmt" + "github.com/jinzhu/gorm" + _ "github.com/jinzhu/gorm/dialects/sqlite" + "github.com/qor/admin" + "net/http" ) // Define a GORM-backend model type User struct { - gorm.Model - Name string + gorm.Model + Name string } // Define another GORM-backend model type Product struct { - gorm.Model - Name string - Description string + gorm.Model + Name string + Description string } func main() { - // Set up the database - DB, _ := gorm.Open("sqlite3", "demo.db") - DB.AutoMigrate(&User{}, &Product{}) + // Set up the database + DB, _ := gorm.Open("sqlite3", "demo.db") + DB.AutoMigrate(&User{}, &Product{}) - // Initalize - Admin := admin.New(&admin.AdminConfig{DB: DB}) + // Initialize + Admin := admin.New(&admin.AdminConfig{DB: DB}) - // Create resources from GORM-backend model - Admin.AddResource(&User{}) - Admin.AddResource(&Product{}) + // Create resources from GORM-backend model + Admin.AddResource(&User{}) + Admin.AddResource(&Product{}) - // Initalize an HTTP request multiplexer - mux := http.NewServeMux() + // Initialize an HTTP request multiplexer + mux := http.NewServeMux() - // Mount admin to the mux - Admin.MountTo("/admin", mux) + // Mount admin to the mux + Admin.MountTo("/admin", mux) - fmt.Println("Listening on: 9000") - http.ListenAndServe(":9000", mux) + fmt.Println("Listening on: 9000") + err := http.ListenAndServe(":9000", mux) + if err != nil { + panic("Error start serve") + } } ```