Looking at the source code mime/multipart it's not possible, but you could implement something like this (note: it's not handling the escaping of filename correctly)
func CreateAudioFormFile(w *multipart.Writer, filename string) (io.Writer, error) {
h := make(textproto.MIMEHeader)
h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="%s"; filename="%s"`, "file", filename))
h.Set("Content-Type", "audio/wav;rate=8000")
return w.CreatePart(h)
}
Outputs
--0c4c6b408a5a8bf7a37060e54f4febd6083fd6758fd4b3975c4e2ea93732 Content-Disposition: form-data; name="file"; filename="helloWorld.wav" Content-Type: audio/wav;rate=8000 --0c4c6b408a5a8bf7a37060e54f4febd6083fd6758fd4b3975c4e2ea93732--
See playground for full example.
Edit: To write the file data, also copy it to the writer as in the original example.
audioFile, _ := CreateAudioFormFile(writer2, "helloWorld.wav")
io.Copy(audioFile, file)
See updated playground for the full example that includes the file data.