package main
import (
"fmt"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
w := c.Writer
header := w.Header()
header.Set("Content-Type", "text/html")
w.WriteHeader(http.StatusOK)
w.Write([]byte(`
<html>
<body>
`))
w.(http.Flusher).Flush()
// 这里对每次循环输出都进行Flush刷新输出
for i := 0; i < 10; i++ {
w.Write([]byte(fmt.Sprintf(`
<h3>%d</h3>
`, i)))
//w.Flush()
w.(http.Flusher).Flush()
time.Sleep(time.Duration(1)*time.Second)
}
w.Write([]byte(`
</body>
</html>
`))
w.(http.Flusher).Flush()
})
r.Run()
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。