Quick Start

GoAdmin makes it easy to use in various web frameworks through various adapters. Currently supported web frameworks are:

You can choose the framework which your own project is using. If there is no framework you like, please feel free to give us an issuearrow-up-right or pr!

Let's take the gin framework for example to demonstrate the build process.

main.go

Firstly, create a new main.go file in your project folder with the following contents:

package main

import (
    _ "github.com/GoAdminGroup/go-admin/adapter/gin" // Import the adapter, it must be imported. If it is not imported, you need to define it yourself.
    _ "github.com/GoAdminGroup/themes/adminlte" // Import the theme
    _ "github.com/GoAdminGroup/go-admin/modules/db/drivers/mysql" // Import the sql driver

    "github.com/GoAdminGroup/go-admin/engine"
    "github.com/GoAdminGroup/go-admin/modules/config"
    "github.com/GoAdminGroup/go-admin/modules/language"
    "github.com/gin-gonic/gin"
)

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

    // Instantiate a GoAdmin engine object.
    eng := engine.Default()

    // GoAdmin global configuration, can also be imported as a json file.
    cfg := config.Config{
        Databases: []config.Database{
            {
                Host:         "127.0.0.1",
                Port:         "3306",
                User:         "root",
                Pwd:          "root",
                Name:         "godmin",
                MaxIdleCon:   50,
                MaxOpenCon:   150,
                Driver:       "mysql",
            },
        },
        UrlPrefix: "admin", // The url prefix of the website.
        // Store must be set and guaranteed to have write access, otherwise new administrator users cannot be added.
        Store: config.Store{
            Path:   "./uploads",
            Prefix: "uploads",
        },
        Language: language.EN,
    }

    // Add configuration and plugins, use the Use method to mount to the web framework.
    _ = eng.AddConfig(cfg).
        Use(r)

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

Please pay attention to the above code and comments, the corresponding steps are added to the comments, it is simple to use. Summary of up to five steps:

  • Import the adapter, the theme and the sql driver

  • Set global configuration items

  • Mounted to the web framework

Then execute go run main.go to run the code and access: http://localhost:9033/admin/loginarrow-up-right default account: admin default password: admin

more web framework example: https://github.com/GoAdminGroup/go-admin/tree/master/examplesarrow-up-right

Add your own business table for management

See:

How To Use Pluginschevron-rightHow To Use Admin Pluginchevron-right

Global configuration item description

https://github.com/GoAdminGroup/go-admin/blob/master/modules/config/config.goarrow-up-right

Logger configuration:

English is not my main language. If any typo or wrong translation you found, you can help to translate in github herearrow-up-right. I will very appreciate it.

Last updated