package main

import (
"fmt"
"github.com/gin-gonic/gin"
"math/rand"
"net/http"
_ "net/http/pprof"
"runtime"
"time"
)

var m = map[int64]int64{}
var r = rand.New(rand.NewSource(time.Now().Unix()))

func main() {
go http.ListenAndServe(":6060", nil)
go func() {
for {
var _ string
}
}()

go func() {
	for {
		time.Sleep(10 * time.Millisecond)
		key := r.Int63()
		m[key] = key
	}
}()
for {
	time.Sleep(1 * time.Second)
	fmt.Println(runtime.NumGoroutine())
}

}

func initHttp() {
router := gin.Default()
router.Use(gin.Recovery())
router.Use(func(context *gin.Context) {
fmt.Println("第一个前")
context.Next()
fmt.Println("第一个后")
})
router.Use(func(context *gin.Context) {
fmt.Println("第二个前")
context.Next()
fmt.Println("第二个后")
})
router.GET("/", func(context *gin.Context) {
fmt.Println("处理器")
fmt.Println("handler")
m := map[string]string{};
m["aaa"] = "bbb";
context.JSON(http.StatusOK, m);
})
go router.Run(":8080")
}