In the Go language world, in addition to the HTML/Template package that comes with the standard library, there are a wide variety of third-party template engine libraries, most of which derive from empirical inheritance from other languages.

Mentioning Go language template engine, many people will naturally think of PonGO2 template engine, which is the first Go language template engine that the author contacted. Almost all Go mainstream popular Web frameworks support it, and you can even see it in xormplus/ XORm database framework library. It is a Template engine for the Go language with django-like syntax, which will be familiar if you have ever done Python development.

Another go-language template engine I like is Jet, which is powerful, efficient, and performs quite well. Another big feature is IDE support, which has an IDEA plugin for developers to use at github.com/jhsx/GoJetP… . This is one of the main Go template engines I use (pongo2 was used in some older projects, and SQL templates in XormPlus/XORm also use Pongo2).

Another template engine library I’d like to mention for the Go language is go-Template, which is more like a template engine adapter, It also supports standard HTML/Template, Amber, Django, Handlebars, PUG (Jade), and Markdown.

The language template engine is mainly divided into two major categories, category are precompiled generating code Go template engine (e.g., the above mentioned these), another kind is to precompile generated Go code template engine, this kind of template engine due to congenital advantage, performance will be better some, whether to adopt this kind of engine, to see your project needs to weigh. The leader of this type of engine is Hero, which is also a Go language template engine library developed by a Chinese.

The Go language template engines used by the author are pongo2, Jet and Hero. If you have another Go template engine library you would like to recommend, please share it in the comments.

Below is a list of Go language template engine libraries I have compiled. I believe there is one for you 🙂

Project Name Stars Forks Description
pongo2 1028 103 Django-syntax like template-engine for Go
mustache 853 128 mustache.go is an implementation of the mustache template language in Go.
hero 795 39 A handy, fast and powerful go template engine.
quicktemplate 794 48 Fast, powerful, yet easy to use template engine for Go. Optimized for speed, zero memory allocations in hot paths.
amber 746 44 Amber is an elegant templating engine for Go Programming Language, inspired from HAML and Jade
ace 616 32 Ace is an HTML template engine for Go. This is inspired by Slim and Jade. This is a refinement of Gold.
gorazor 594 70 GoRazor is the Go port of the razor view engine originated from asp.net in 2011.
jet 400 22 Jet is a template engine developed to be easy to use, powerful, dynamic, yet secure and very fast.
ego 323 25 Ego is an ERb style templating language for Go. It works by transpiling templates into pure Go and including them at compile time. These templates are light wrappers around the Go language itself.
raymond 186 16 Handlebars for golang
fasttemplate 143 24 Simple and fast template engine for Go
soy 120 18 Go implementation for Soy templates (Google Closure templates)
kasia.go 70 5 Kasia.go is a Go implementation of the Kasia templating system.
ftmpl 49 1 Fast typesafe templating for golang
go-template 30 3 The best way to work with different type of Template Engines and Parsers for Go Programming Language
damsel 19 1 Markup language featuring html outlining via css-selectors, extensible via pkg html/template and others.
Ego 15 0 Embedded Go — a Go-like template language

Here are some performance comparisons from the Go Template Engine library

full featured template engines

Name Runs (including s/op B/op allocations/op
Ace 500000 8.972 1712 42
Amber 1000000 5.628 1440 38
Golang 1000000 5.379 1360 37
Handlebars 500000 10.174 4210 82
JetHTML 3000000 1.209 0 0
Kasia 1000000 3.351 1184 25
Mustache 1000000 3.544 1568 28
Pongo2 1000000 4.681 2360 46
Soy 1000000 3.067 1376 25

precompilation to Go code

Name Runs (including s/op B/op allocations/op
Ego 5000000 0.793 85 8
Egon 3000000 1.541 149 12
EgonSlinso 20000000 0.311 0 0
Ftmpl 3000000 1.298 1141 12
Gorazor 5000000 1.014 613 11
Hero 30000000 0.162 0 0
Quicktemplate 20000000 0.289 0 0