package main import ( "log" "os" "os/signal" "time" _ "github.com/GoAdminGroup/go-admin/adapter/beego" _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql" "github.com/GoAdminGroup/go-admin/engine" "github.com/GoAdminGroup/go-admin/examples/datamodel" "github.com/GoAdminGroup/go-admin/modules/config" "github.com/GoAdminGroup/go-admin/modules/language" "github.com/GoAdminGroup/go-admin/plugins/example" "github.com/GoAdminGroup/go-admin/template" "github.com/GoAdminGroup/go-admin/template/chartjs" "github.com/GoAdminGroup/themes/adminlte" "github.com/astaxie/beego" ) func main() { app := beego.NewApp() eng := engine.Default() cfg := config.Config{ Env: config.EnvLocal, Databases: config.DatabaseList{ "default": { Host: "127.0.0.1", Port: "3306", User: "root", Pwd: "root", Name: "godmin", MaxIdleConns: 50, MaxOpenConns: 150, ConnMaxLifetime: time.Hour, Driver: config.DriverMysql, }, }, Store: config.Store{ Path: "./uploads", Prefix: "uploads", }, UrlPrefix: "admin", IndexUrl: "/", Debug: true, Language: language.CN, ColorScheme: adminlte.ColorschemeSkinBlack, } template.AddComp(chartjs.NewChart()) // customize a plugin examplePlugin := example.NewExample() // load from golang.Plugin // // examplePlugin := plugins.LoadFromPlugin("../datamodel/example.so") // customize the login page // example: https://github.com/GoAdminGroup/demo.go-admin.cn/blob/master/main.go#L39 // // template.AddComp("login", datamodel.LoginPage) // load config from json file // // eng.AddConfigFromJSON("../datamodel/config.json") beego.SetStaticPath("/uploads", "uploads") if err := eng.AddConfig(&cfg). AddGenerators(datamodel.Generators). AddDisplayFilterXssJsFilter(). // add generator, first parameter is the url prefix of table when visit. // example: // // "user" => http://localhost:9033/admin/info/user // AddGenerator("user", datamodel.GetUserTable). AddPlugins(examplePlugin). Use(app); err != nil { panic(err) } // you can custom your pages like: eng.HTML("GET", "/admin", datamodel.GetContent) beego.BConfig.Listen.HTTPAddr = "127.0.0.1" beego.BConfig.Listen.HTTPPort = 9087 go app.Run() quit := make(chan os.Signal, 1) signal.Notify(quit, os.Interrupt) <-quit log.Print("closing database connection") eng.MysqlConnection().Close() }