Go 课程
Go 并行计算的核心-Goroutine
Go 中比较核心的概念:协程(Coroutine),在 Go 中被改写之后称之为:Goroutine,它是并发模型的基本执行单元。事实上每一个Go程序至少有一个Goroutine:主Goroutine。当程序启动时,它会自动创建
生成 go.mod文件:
1 Go mod init mod-demo
执行命令go list -m all 查看当前所有依赖项
Go web 框架 Gin (https://gin-gonic.com/) (https://github.com/gin-gonic/gin)
use the below Go command to install Gin.
go get -u github.com/gin-gonic/gin
Import it in your code:
import "github.com/gin-gonic/gin"
1package main
2import "github.com/gin-gonic/gin"
3func main() {
4 r := gin.Default()
5 r.GET("/ping", func(c *gin.Context) {
6 c.JSON(200, gin.H{
7 "message": "pong, hello world!",
8 })
9 })
10 r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
11}