Skip to content

Instantly share code, notes, and snippets.

@edevil
Created January 8, 2018 17:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save edevil/8a47d4cf8f34bf2f64f2520db5bcd986 to your computer and use it in GitHub Desktop.
Dep strangeness
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
[[constraint]]
name = "github.com/jinzhu/gorm"
version = "1.0.0"
[[constraint]]
name = "github.com/mattn/go-sqlite3"
version = "1.4.0"
[[constraint]]
name = "github.com/qor/admin"
revision = "009cc1290581761ac6fe8c837681c03891c27368"
[[constraint]]
name = "github.com/qor/render"
revision = "63566e46f01b134ae9882a59a06518e82a903231"
[[constraint]]
name = "github.com/qor/responder"
revision = "b6def473574f621fee316696ad120d4fbf470826"
[[constraint]]
name = "github.com/qor/redirect_back"
revision = "b4161ed6f84819fb3a2d13d5c9e6872ef76d8128"
[[constraint]]
name = "github.com/qor/roles"
revision = "d6375609fe3e5da46ad3a574fae244fb633e79c1"
[[constraint]]
name = "github.com/qor/qor"
revision = "1c17696527773fa844a809b0ff06f79559f4d336"
[[constraint]]
name = "github.com/qor/validations"
revision = "f364bca61b46bd48a5e32552a37758864fdf005d"
package main
import (
"fmt"
"net/http"
"github.com/jinzhu/gorm"
_ "github.com/mattn/go-sqlite3"
"github.com/qor/admin"
"github.com/qor/auth"
"github.com/qor/qor"
)
// Create a GORM-backend model
type User struct {
gorm.Model
Name string
}
// Create another GORM-backend model
type Product struct {
gorm.Model
Name string
Description string
}
func main() {
DB, _ := gorm.Open("sqlite3", "demo.db")
DB.AutoMigrate(&User{}, &Product{})
// Initalize
Admin := admin.New(&qor.Config{DB: DB})
// Allow to use Admin to manage User, Product
Admin.AddResource(&User{})
Admin.AddResource(&Product{})
// Initialize Auth
Auth := auth.New(&auth.Config{DB: DB})
// initalize an HTTP request multiplexer
mux := http.NewServeMux()
// Mount admin interface to mux
Admin.MountTo("/admin", mux)
fmt.Println("Listening on: 9000")
http.ListenAndServe(":9000", mux)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment