golang template example
Example: go template
package main
import (
"fmt"
"html/template"
"net/http"
"os"
)
type Person struct {
Name string
Age int
}
func main() {
os.Setenv("PORT", "3000")
port := os.Getenv("PORT")
html, _ := template.ParseFiles("index.html")
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
person := Person{Name: "john doe", Age: 23}
fmt.Println(html.Execute(w, person))
})
http.ListenAndServe(":"+port, nil)
}