I have been in DevOps related jobs for past 6 years dealing mainly with Kubernetes in AWS and on-premise as well. I spent quite a lot …
:date_long | 1 min Read
Go include template
package main
import (
"os"
// "time"
"fmt"
"log"
// "math"
"text/template"
)
var tpl *template.Template
func init() {
fmt.Println("Initializing ...")
// tpl = template.Must(template.ParseGlob("*.gohtml"))
// to incorporate some extra function into template object
tpl = template.Must(template.ParseFiles("someindex.gohtml", "polarBearTemplate.gohtml"))
}
func main() {
err := tpl.ExecuteTemplate(os.Stdout, "someindex.gohtml", 42)
if err != nil {
log.Fatalln(err)
}
}
someindex.gohtml
My Peeps
{{template "polarbear" .}}