/go-admin

A golang framework helps gopher to build a data visualization and admin panel in ten minutes

Primary LanguageGoApache License 2.0Apache-2.0

go-admin

the missing golang data admin panel builder tool.

Documentation | 中文文档 | DEMO

Go Report Card Go Report Card golang telegram slack GoDoc license

Inspired by laravel-admin

Preface

GoAdmin is a toolkit to help you build a data visualization admin panel for your golang app.

demo: https://demo.go-admin.com account: admin password: admin

demo source code: https://github.com/GoAdminGroup/demo.go-admin.cn

interface

Features

  • 🚀 Fast: build a production admin panel app in ten minutes.
  • 🎨 Theming: beautiful ui themes supported(default adminlte, more themes are coming.)
  • 🔢 Plugins: many plugins to use(more useful and powerful plugins are coming.)
  • Rbac: out of box rbac auth system.
  • ⚙️ Frameworks: support most of the go web frameworks.

Translation

We need your help: GoAdminGroup/docs#1

Who is using

Comment the issue to tell us.

How to

Following three steps to run it.

Step 1: import sql

mysql postgresql sqlite

Step 2: create main.go

main.go

package main

import (
	"github.com/gin-gonic/gin"
	_ "github.com/GoAdminGroup/go-admin/adapter/gin"
	_ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql"
	"github.com/GoAdminGroup/go-admin/engine"
	"github.com/GoAdminGroup/go-admin/plugins/admin"
	"github.com/GoAdminGroup/go-admin/modules/config"
	"github.com/GoAdminGroup/themes/adminlte"
	"github.com/GoAdminGroup/go-admin/template"
	"github.com/GoAdminGroup/go-admin/template/chartjs"
	"github.com/GoAdminGroup/go-admin/template/types"
	"github.com/GoAdminGroup/go-admin/examples/datamodel"
	"github.com/GoAdminGroup/go-admin/modules/language"
)

func main() {
	r := gin.Default()

	eng := engine.Default()

	// global config
	cfg := config.Config{
		Databases: config.DatabaseList{
			"default": {
				Host:         "127.0.0.1",
				Port:         "3306",
				User:         "root",
				Pwd:          "root",
				Name:         "godmin",
				MaxIdleCon: 50,
				MaxOpenCon: 150,
				Driver:       "mysql",
			},
        	},
		UrlPrefix: "admin",
		// STORE is important. And the directory should has permission to write.
		Store: config.Store{
		    Path:   "./uploads", 
		    Prefix: "uploads",
		},
		Language: language.EN,
		// debug mode
		Debug: true,
		// log file absolute path
		InfoLogPath: "/var/logs/info.log",
		AccessLogPath: "/var/logs/access.log",
		ErrorLogPath: "/var/logs/error.log",
		ColorScheme: adminlte.ColorschemeSkinBlack,
	}

    	// Generators: see https://github.com/GoAdminGroup/go-admin/blob/master/examples/datamodel/tables.go 
	adminPlugin := admin.NewAdmin(datamodel.Generators)
	
	// add component chartjs
	template.AddComp(chartjs.NewChart())
	
	// add generator, first parameter is the url prefix of table when visit.
    	// example:
    	//
    	// "user" => http://localhost:9033/admin/info/user
    	//
    	adminPlugin.AddGenerator("user", datamodel.GetUserTable)
	
	// customize your pages
    
    	r.GET("/admin", func(ctx *gin.Context) {
    		eng.Content(ctx, func(ctx interface{}) (types.Panel, error) {
    			return datamodel.GetContent()
    		})
    	})

	_ = eng.AddConfig(cfg).AddPlugins(adminPlugin).Use(r)

	_ = r.Run(":9033")
}

More Examples: https://github.com/GoAdminGroup/go-admin/tree/master/examples

Step 3: run

GO111MODULE=on go run main.go

visit: http://localhost:9033/admin

A super simple example here

See the docs for more details.

Backers

Your support will help me do better! [Become a backer]

Contribution

here for contribution guide

here to join into the develop team

join telegram