net/http: FormValue doesn't take the body parameter precedence over the URL query string value #64575
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Go version
go version go1.20.6 darwin/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
https://pkg.go.dev/net/http#Request.FormValue
FormValue returns the first value for the named component of the query. POST and PUT body parameters take precedence over URL query string values. FormValue calls ParseMultipartForm and ParseForm if necessary and ignores any errors returned by these functions. If key is not present, FormValue returns the empty string. To access multiple values of the same key, call ParseForm and then inspect Request.Form directly.
Sample application:
https://go.dev/play/p/B_9IyJ7YTEL
What did you expect to see?
curl --location 'http://127.0.0.1:8080/?name=potato' --form 'name="orange"'
Expected output should be:
Because the POST and PUT body parameters take precedence over URL query string values.
What did you see instead?
Server output:
The text was updated successfully, but these errors were encountered: