Categorygithub.com/wuruipeng404/scaffold
repositorypackage
1.5.10
Repository: https://github.com/wuruipeng404/scaffold.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

Scaffold

  • Scaffolding for quickly building web services based on gin and zap

install

go get -u github.com/wuruipeng404/[email protected]

Usage


package main

import (
	"context"
	"github.com/gin-gonic/gin"
	"github.com/wuruipeng404/scaffold"
	"github.com/wuruipeng404/scaffold/logger"
	"github.com/wuruipeng404/scaffold/orm"
	"sync"
)

func init() {
	logger.InitLogger() // only os.stdout

	logger.InitPersistenceLogger("./some_logfile")
}

func main() {
	server := scaffold.NewGraceServer(":8000", gin.Default())

	server.AddBackgroundTask(func(ctx context.Context, wg *sync.WaitGroup) {
		// some background task like cronjob
	})

	server.AddDeferFunc(func() {
		// resource recycle
		logger.Debugf("exit")
	})
	server.Start()
}