<file_sep>package routers

import (
	"github.com/gin-gonic/gin"
	v1 "yhdm/api/v1"
)

func Routers()  *gin.Engine{
	r :=gin.Default()
	// 添加路由
	r.GET("/home",v1.Testget)

	
	return r
}
<file_sep>package global

import "github.com/sirupsen/logrus"

var (
	LOG *logrus.Logger

)
<file_sep>package log

import (
	"fmt"
	"github.com/sirupsen/logrus"
	"strings"
	"time"
)

type MyFormatter struct{}

func (s *MyFormatter) Format(entry *logrus.Entry) ([]byte, error) {
	timestamp := time.Now().Local().Format("2006/01/02 15:04:05")
	msg := fmt.Sprintf("[CAI-%s] %s  %s\n",strings.ToUpper(entry.Level.String()),timestamp, entry.Message)
	return []byte(msg), nil
}
func InitLogger() *logrus.Logger  {
	var log = logrus.New()
	log.SetFormatter(new(MyFormatter))
	return log
}<file_sep>package main

import (
	"yhdm/global"
	"yhdm/log"
)

func main() {
	global.LOG =  log.InitLogger()
	global.LOG.Info("gin run")
	global.InitGlobal("127.0.0.1:7999")
}<file_sep>package v1

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func Testget(c *gin.Context) {
	c.JSON(http.StatusOK, gin.H{
		"name":   "hello",
		"number": "123456",
	})
}

