cgo

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: MIT Imports: 24 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

cgo

My mini Go web framework base on gin

Require

github.com/gin-gonic/gin
github.com/go-ini/ini
github.com/jinzhu/gorm

Documentation

Index

Constants

This section is empty.

Variables

define Config struct

View Source
var Db *gorm.DB
View Source
var Logger *logrus.Logger
View Source
var Redis redisClient

Functions

func Debug

func Debug(format string, values ...interface{})

Debug

func LoadConfig

func LoadConfig(path string, resp interface{})

Load config

func Loginfo

func Loginfo(format string, values ...interface{})

Log info to file

func LogrusMiddleware

func LogrusMiddleware() gin.HandlerFunc

func New

func New(conf *CgoConfig) (g *gin.Engine)

New cgo with gin

func NewConfig

func NewConfig(path string)

new Config

func NewLogrus

func NewLogrus() *logrus.Logger

func NewMysql

func NewMysql()

init mysql by gorm

func NewRedis

func NewRedis() *redis.Client

func NewTemplate

func NewTemplate(engine *gin.Engine, c *CgoConfig)

Use template

func Pagination

func Pagination(page int, pageSize int, out interface{}, orderBy string, where string) error

查询分页数据

func Response404Err

func Response404Err(ctx *gin.Context)

返回 404错误 json

func ResponseNoAuth

func ResponseNoAuth(ctx *gin.Context)

返回 权限校验 失败json

func ResponseParamErr

func ResponseParamErr(ctx *gin.Context)

返回 参数校验 失败json

func ResponseSuccess

func ResponseSuccess(ctx *gin.Context, data interface{})

返回 成功json

func Run

func Run(gin *gin.Engine)

func ServerErr

func ServerErr(ctx *gin.Context, err string)

返回 服务错误 json

func Unescaped

func Unescaped(x string) interface{}

unescape template html content

func View

func View(ctx *gin.Context, code int, tpl string, obj interface{})

Load template

func View404

func View404(ctx *gin.Context, tpl string)

Types

type CgoConfig

type CgoConfig struct {
	ConfigPath string
	TplFuncMap template.FuncMap
}

type JsonData

type JsonData struct {
	Code int         `json:"code""`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func JsonMsg

func JsonMsg(code int, obj interface{}, msg string) *JsonData

统一json输出格式

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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