the missing golang admin builder tool.
as a admin platform. the following principle is important as i see.
- security and easy to use
- independent of business platform
- beautiful admin interface builder powerd by adminlte
- configurable which help manage your database data easily
- powerful auth manage system
- writed by go
- portable
- easy to deploy
only from source now.
cd $GOPATH/src
git clone https://github.com/chenhg5/go-admin
mv go-admin goAdmin
./goman create --table=user
models/user.go
package models
func GetUserTable() (userTable GlobalTable) {
// 列显示配置
userTable.Info.FieldList = []FieldStruct{
{
Head: "姓名",
Field: "name",
TypeName: "varchar",
ExcuFun: func(model RowModel) string {
return model.Value
},
},
{
Head: "性别",
Field: "sex",
TypeName: "tinyint",
ExcuFun: func(model RowModel) string {
if model。Value == "1" {
return "男"
}
if model。Value == "2" {
return "女"
}
return "未知"
},
},
}
userTable.Info.Table = "users"
userTable.Info.Title = "用户表"
userTable.Info.Description = "用户表"
// 表单显示配置
userTable.Form.FormList = []FormStruct{
{
Head: "姓名",
Field: "name",
TypeName: "varchar",
Default: "",
Editable: true,
FormType: "default",
}, {
Head: "性别",
Field: "sex",
TypeName: "tinyint",
Default: "",
Editable: true,
FormType: "text",
},
}
userTable.Form.Table = "users"
userTable.Form.Title = "用户表"
userTable.Form.Description = "用户表"
return
}
- models/global.go
package models
// map下标是路由前缀,对应的值是GlobalTable类型,为表单与表格的数据抽象表示
var GlobalTableList = map[string]GlobalTable{
"user": GetUserTable(),
}
- config/config.go
package config
var EnvConfig = map[string]interface{}{
"SERVER_PORT": ":4003",
"DATABASE_IP": "127.0.0.1",
"DATABASE_PORT": "3306",
"DATABASE_USER": "root",
"DATABASE_PWD": "root",
"DATABASE_NAME": "goadmin",
"DATABASE_MAX_IDLE_CON": 50, // 连接池连接数
"DATABASE_MAX_OPEN_CON": 150, // 最大连接数
"REDIS_IP": "127.0.0.1",
"REDIS_PORT": "6379",
"REDIS_PASSWORD": "",
"REDIS_DB": 1,
"PORTABLE": false, // 是否跨平台可移植
"AUTH_DOMAIN": "localhost",
}
import admin.sql into database
make deps
make
visit http://localhost:4003/login by browser
login with username:admin, password:admin
- build
- test
- clean
- run
- restart
- deps : install dependency
- cross : cross compile
- pages : compile html into go file
- assets : compile assets into go file
- fmt
- add go-bindata support
- add more components
- menu structure
- rcba auth
- custom pages
- combine assets
- auto install engine
- demo site
- performance analysis
very welcome to pr
here to join into the develop team
QQ Group Num: 756664859
inspired by laravel-admin