gobui

package module
v0.0.0-...-8d59c21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

README

Gobui

Golang业务后端开发的适用性探究

使用

模块

go get -u github.com/rwcoding/gobui

入口

main.go

package main

import (
	"github.com/rwcoding/gobui"
	"github.com/rwcoding/gobui/config"
	_ "github.com/rwcoding/gobui/module"
	"log"
)

func main() {
	app := gobui.DefaultApp()
	err := app.Run(config.Addr())
	if err != nil {
		log.Fatal(err)
	}
}
配置

config.json

{
  "env": "dev",
  "addr": ":8080",
  "log": "",

  "db" : {
    "host": "127.0.0.1",
    "port": 3306,
    "username": "root",
    "password": "root",
    "dbname": "gobui",
    "charset": "utf8mb4",

    "pool_max_open": 100,
    "pool_max_idle": 50,
    "pool_max_life": 600
  }
}
运行
go run main.go

查看:http://127.0.0.1:8080

配置文件优先级

  • 运行时指定绝对目录:--conf /etc/config.json
  • 可执行文件当前目录的 config.json 文件
  • 运行终端所在目录的 config.json 文件

发布版本测试

  • 导入数据库(MySQL) gobui.sql
  • 配置 config.json
  • 运行 gobui.linux --conf /etc/config.json, 不指定配置文件,默认读取可执行文件当前目录的 config.json 文件
  • windows 系统使用 gobui.windows.exe
  • 测试打包文件仅仅 amd64 环境

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func App

func App() *gin.Engine

func DefaultApp

func DefaultApp() *gin.Engine

func Init

func Init()

func InitDefault

func InitDefault()

func Route

func Route(str string, handler HandleFunc, name string)

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (*Context) Error

func (c *Context) Error(err error)

func (*Context) GetAdminer

func (c *Context) GetAdminer() *models.Adminer

func (*Context) GetRemote

func (c *Context) GetRemote() string

func (*Context) GetSession

func (c *Context) GetSession() string

func (*Context) GetTime

func (c *Context) GetTime() int

func (*Context) GinCtx

func (c *Context) GinCtx() *gin.Context

func (*Context) NewRequest

func (c *Context) NewRequest(r interface{}) error

func (*Context) Render

func (c *Context) Render(response *api.Response)

func (*Context) Verify

func (c *Context) Verify() *api.Response

type HandleFunc

type HandleFunc func(ctx *Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL