Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8956847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:51:40+00:00 2026-06-15T14:51:40+00:00

I am trying to process a simple html form in go. However, I am

  • 0

I am trying to process a simple html form in go. However, I am unable to get any post data upon submission. The r.Form map is always []. Don’t know where I am going wrong.

Thanks in advance.

Here is the code http://play.golang.org/p/aZxPCcRAVV

package main

import (
    "html/template"
    "log"
    "net/http"
)

func rootHandler(w http.ResponseWriter, r *http.Request) {
    t, _ := template.New("form.html").Parse(form)
    t.Execute(w, "")
}

func formHandler(w http.ResponseWriter, r *http.Request) {
    log.Println(r.Form)
    rootHandler(w, r)
}

func main() {
    http.HandleFunc("/", rootHandler)
    http.HandleFunc("/login", formHandler)
    http.ListenAndServe("127.0.0.1:9999", nil)
}

var form = `
<h1>Login</h1>
<form action="/login" method="POST">
<div><input name="username" type="text"></div>
<div><input type="submit" value="Save"></div>
</form>
`
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:51:40+00:00Added an answer on June 15, 2026 at 2:51 pm

    Looks like you need to call ParseForm first. From the go docs

    // Form contains the parsed form data, including both the URL
    // field's query parameters and the POST or PUT form data.
    // This field is only available after ParseForm is called.
    // The HTTP client ignores Form and uses Body instead.
    Form url.Values
    

    And some code to get your example working.

    func formHandler(w http.ResponseWriter, r *http.Request) {
        err := r.ParseForm()
        if err != nil {
           //handle error http.Error() for example
           return
        }
        log.Println(r.Form)
        rootHandler(w, r)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to process the submitted results for a form, containing data for
I am trying to write a simple HTML form using asp.net and Jquery UI
I'm trying to integrate a simple Rails app with a BPEL process but it's
So I'm trying to create a simple (if such one exists) login process for
I'm trying to process data obtained from a run of diff to an instance
I'm trying to figure out how to get a response back from my $.post()
I'm in the process of learning Javascript and I'm trying to create a simple
I need to remotely submit/process a form on an external website and get the
I am trying to include a very simple header.html to my index.php but it
I'm using Simple HTML Dom . I'm trying to run the following: (with WAMP)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.