登陆
Golang 开源网站模板示例:
```go
package main
import (
"fmt"
"html/template"
"net/http"
)
func main() {
// 定义模板文件路径
templatePath := "example.html"
// 创建模板引擎
template引擎 := template.New("example")
// 创建模板文件并解析
err := template引擎.Parse(templatePath)
if err != nil {
fmt.Println(err)
return
}
// 创建 HTTP 客户端
client :=