There is no template engine on Go or GoLang. Because the language itself already supports it without any third party.
A template processor (also known as a template engine or template parser) is software designed to combine templates with a data model to produce result documents. The language that the templates are written in is known as a template language or templating language.
There are many template engines for many programming languages:
How cool it is. Go is so simple and modern. Go was born with a template engine feature. So, we don't need any third party or alternative. Let me bring how to work with the Go template in a single article here.
There are built-in packages named "templates" under "html" and "text" packages. You can check them here, https://golang.org/pkg/:
Templates are executed by applying them to a data structure. Annotations in the template refer to elements of the data structure (typically a field of a struct or a key in a map) to control execution and derive values to be displayed. Execution of the template walks the structure and sets the cursor, represented by a period '.' and called "dot", to the value at the current location in the structure as execution proceeds.
I tried to print out inline JavaScript in the head. Of course, it is not safe to against code injection and can cause Cross-Site Scripting (XSS). The safe one is to use from "html" package.
I tried to print out the raw HTML tag, script, into the pre tag. The Go code is the same as above. We just need to change the built-in package from "text/template" to "html/template".
Go template can be inside of files or string variables. We can use any file extension for files that contain only strings of the Go template. The most common file extensions are .gohtml, .tmpl, or .tpl.
Variable
Here is an example of using variables inside the Go template.
<!DOCTYPE html><html><head><metacharset="UTF-8"><title>Struct</title></head><body><h1>Struct</h1><p>His name is {{.Name}}. His age is {{.Age}}.</p></body></html>
Complex
Here is an example if we want to pass a slice or map inside a struct.
Those are examples of the Go template. For full reference, you can go to the documentation of the text and HTML template packages. The source code for this article is at https://github.com/aristorinjuang/go-templates.