This example will show how to simulate a contact form and parse the message into a struct using GO lang with html/template and net/http packages.

// forms.go
package main

import (

type ContactDetails struct {
    Email   string
    Subject string
    Message string

func main() {
    tmpl := template.Must(template.ParseFiles("forms.gohtml"))

    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        if r.Method != http.MethodPost {
            tmpl.Execute(w, nil)

        details := ContactDetails{
            Email:   r.FormValue("email"),
            Subject: r.FormValue("subject"),
            Message: r.FormValue("message"),

        // do something with details
        _ = details

        tmpl.Execute(w, struct{ Success bool }{true})

    http.ListenAndServe(":8080", nil)

This is a form .gohtml code

<!-- forms.gohtml -->
{{if .Success}}
    <h1>Thanks for your message!</h1>
    <form method="POST">
        <label>Email:</label><br />
        <input type="text" name="email"><br />
        <label>Subject:</label><br />
        <input type="text" name="subject"><br />
        <label>Message:</label><br />
        <textarea name="message"></textarea><br />
        <input type="submit">

Run GO code and test it

$ go run forms.go