-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (46 loc) · 943 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"crypto/rand"
"encoding/hex"
"fmt"
)
func main() {
b := make([]byte, 20)
fmt.Println(b) //
_, err := rand.Read(b)
if err != nil {
fmt.Println(err.Error())
}
id := hex.EncodeToString(b)
fmt.Println(id)
//router := gin.Default()
//router.GET("/", func(c *gin.Context) {
// time.Sleep(5 * time.Second)
// c.String(http.StatusOK, "Welcome Gin Server")
//})
//
//srv := &http.Server{
// Addr: ":8080",
// Handler: router,
//}
//
//go func() {
// // 服务连接
// if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
// log.Fatalf("listen: %s\n", err)
// }
//}()
//
//// 优雅关闭
//shutdown.NewHook().Close(
// // 关闭 http server
// func() {
// ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
// defer cancel()
//
// if err := srv.Shutdown(ctx); err != nil {
// log.Fatal("Server Shutdown:", err)
// }
// },
//)
}