Problems parsing HTTP POST multipart/form-data

Hello, this is my first post here on this forum.
I have a problem in parsing multipart/form-data.
Here is what I did:

func handleIncomingUploads(w http.ResponseWriter, r *http.Request){
        r.ParseMultipartForm(math.MaxInt64)

	log.Printf("%#v", r.Header.Get("Content-Type"))

	username:=r.FormValue("username")
	imei:=r.PostFormValue("imei")
	log.Println(username)
	log.Println(imei)

	file, handler, err:=r.FormFile("file")
	if err!=nil{
		log.Println("Error retrieving the file:", err)
		return
	}
	defer file.Close()

	log.Printf("Uploaded File: %+v\n", handler.Filename)
	log.Printf("File Size: %+v\n", handler.Size)
	log.Printf("MIME Header: %+v\n", handler.Header)


	fileBytes, err := ioutil.ReadAll(file)
	if err != nil {
		log.Println(err)
	}

	filepath:="boom-"+username

	err=ioutil.WriteFile(filepath, fileBytes, 0777)
	if err != nil {
		log.Println(err)
	}

	log.Println("File successfully uploaded.")
}

What I’m doing here is trying to parse a form having three fields: username, imei and file.
The last one contains a file (obviously) and it is well parsed and saved by this code.
Now the problem is on the other two, they are two string values, but they are not correctly parsed, i have an empty string.

I made some attempts using Postman and I noticed that those two fields are correctly parsed only if I choose x-www-form-urlencoded instead of form-data.
So I can’t understand what’s wrong here. Can someone help me please?

Thanks in advance.

Yesterday I finally figured out where the problem was (and it makes me feel like an idiot).
The problem is in ParseMultipartForm(math.MaxInt64), in particular in the parameter passed to the function. Reading the docs I saw what is the purpose of this parameter, that is to tell how much memory must be allocated in RAM to parse the data contained in the form. Now, MaxInt64 is just a little bigger than the memory available on my machine… 8589934591 GB.

So the solution to my problem was to set a correct value of memory to allocate for parsing.

I have spent the entire day because of this, thanks so much for posting! In my case, I couldn’t figure out why it was working properly locally, but on deploy, the files were simply empty. Changing the max to 0 solved it.

But, why would this happen? As far as I understood from the docs, the max is just the maximum allowed to be allocated, not the minimum memory required?