O'Reilly logo

Go Standard Library Cookbook by Radomir Sohlich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

The Request struct of the net/http package contains the Form field which contains the POST form variables and URL query variables merged. The important step in the preceding code is the call of the ParseForm method on the Request pointer. This method call causes the parsing of the POST form values and query values into a Form variable. Note that if the Get method on the Form field is used, the POST value of the parameter is prioritized. The Form and PostForm fields are, in fact, of type url.Values.

If only the parameters from the POST form need to be accessed, the PostForm field of the Request is provided. This one keeps only those that were part of the POST body.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required