我开始使用 Golang 的 Web 框架(Iris)。我正在使用来自 gitbooks 的官方 iris 书。我正在处理本书本页中的最后一个示例。以下是上一个示例中使用的代码
./templates/hi.html
<!-- ./templates/hi.html -->
<html><head> <title> Hi Iris [THE TITLE] </title> </head>
<body>
<h1> Hi {{ Name }}
</body>
</html>
./main.go
// ./main.go
import (
"github.com/kataras/iris"
)
func main() {
iris.Config.Render.Template.Engine = iris.PongoEngine
iris.Get("/hi", hi)
iris.Listen(":8080")
}
func hi(ctx *iris.Context){
ctx.Render("hi.html", map[string]interface{}{"Name": "iris"})
}
当我运行 main.go 时,以下是我得到的错误。
# command-line-arguments
./main.go:8: iris.Config.Render undefined (type *config.Iris has no field or method Render)
./main.go:8: undefined: iris.PongoEngine
我正确执行了所有步骤,还下载了所有依赖项。我已经学习了Learn How To Code: Google's Go (golang) Programming Language - Udemy and Golang Workshop by Caleb Doxcy,所以我知道基础知识,例如如何安装依赖项,以及如何导入它们等。但是书中显示的示例不起作用。