go语言 echo框架
by Ying Kit Yuen
英杰苑
如何在Go Echo Web框架中设置嵌套HTML模板 (How to setup a nested HTML template in the Go Echo web framework)
Echo is a lightweight but complete web framework in Go for building RESTful APIs. It is fast and includes a bunch of middleware for handling the whole HTTP request-response cycle. For the rendering part, it works with any template engine, but I use the standard html/template package for the purpose of simplicity. By the end of this article, we will have a nested template Echo project setup.
Echo是Go中一个轻量级但完整的Web框架,用于构建RESTful API。 它速度很快,并且包括一堆用于处理整个HTTP请求-响应周期的中间件。 对于呈现部分,它可以与任何模板引擎一起使用,但是出于简化的目的,我使用标准的html / template包。 到本文结尾,我们将有一个嵌套的模板Echo项目设置。
If you already have an idea on how Echo works, jump to the Using a nested template section.
如果您已经对Echo的工作原理有所了解,请跳至使用嵌套模板部分 。
基本的Echo项目设置 (A basic Echo project setup)
在正确的$ GOPATH下创建项目文件夹 (Create the project folder under the proper $GOPATH)
The complete project code is hosted on Gitlab. First we’ll create the project folder here: $GOPATH/src/gitlab.com/ykyuen/golang-echo-template-example.
完整的项目代码托管在Gitlab上 。 首先,我们将在此处创建项目文件夹: $ GOPATH / src / gitlab.com / ykyuen / golang-echo-template-example 。