gin can not run reasons: c.engine.AppEngine undefined
gin运行报错:
源码:
版本兼容性问题,降级到 gin@1.7.2 即可解决问题。
当前最新的版本为1.7.5
降级方法:
go get github.com/gin-gonic/gin@v1.7.2
原创文章,转载请注明出处:
http://30daydo.com/article/44289
# github.com/gin-gonic/gin
C:\Users\xda\go\pkg\mod\github.com\gin-gonic\gin@v1.7.5\context.go:735:13: c.engine.AppEngine undefined (type *Engine ha
s no field or method AppEngine)
C:\Users\xda\go\pkg\mod\github.com\gin-gonic\gin@v1.7.5\gin.go:154:3: unknown field 'UseRawPath' in struct literal of ty
pe Engine
C:\Users\xda\go\pkg\mod\github.com\gin-gonic\gin@v1.7.5\gin.go:156:3: unknown field 'UnescapePathValues' in struct liter
al of type Engine
C:\Users\xda\go\pkg\mod\github.com\gin-gonic\gin@v1.7.5\gin.go:508:11: engine.UseRawPath undefined (type *Engine has no
field or method UseRawPath)
C:\Users\xda\go\pkg\mod\github.com\gin-gonic\gin@v1.7.5\gin.go:510:20: engine.UnescapePathValues undefined (type *Engine
has no field or method UnescapePathValues)
源码:
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
// 1.创建路由
r := gin.Default()
// 2.绑定路由规则,执行的函数
// gin.Context,封装了request和response
r.GET("/", func(c *gin.Context) {
c.String(http.StatusOK, "hello World!")
})
// 3.监听端口,默认在8080
// Run("里面不指定端口号默认为8080")
r.Run(":8000")
}
版本兼容性问题,降级到 gin@1.7.2 即可解决问题。
当前最新的版本为1.7.5
降级方法:
go get github.com/gin-gonic/gin@v1.7.2
原创文章,转载请注明出处:
http://30daydo.com/article/44289