使用:
go get -u github.com/gin-gonic/gin
出现以下错误:
unrecognized import path "gopkg.in/yaml.v2": https fetch: Get "https://gopkg.in/yaml.v2?go-get=1": dial tcp xxxxxxxx:443: i/o timeout
于是通过下面的步骤解决:
cd C:\Users\ahfuzhang\go\src\github.com
git clone "https://github.com/gin-gonic/gin.git"
搜索所有文件中的"gopkg.in/yaml.v2"
替换为:"github.com/go-yaml/yaml"
然后以下的测试代码顺利编译通过并运行:
package main
import (
"github.com/gin-gonic/gin"
)
func main(){
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run()
}
|
请发表评论