go学习00

下载gin失败

解决办法:
cmd输入
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
即可安装gin包
go get github.com/gin-gonic/gin

goland中go.mod的require是灰色

解决办法:

即可愉快运行Demo

package main

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

func main() {
	
	ginServer := gin.Default()

	ginServer.GET("/", func(c *gin.Context) {
		c.JSON(200, gin.H{"msg": "hello world"})
	})

	ginServer.Run(":8080")
}
posted @ 2024-04-24 23:28  wushucan  阅读(11)  评论(0)    收藏  举报