Golang mime/multipart.Writer.WriteField() function example
package mime/multipart
Golang mime/multipart.Writer.WriteField() function usage example
....
var b bytes.Buffer
w := NewWriter(&b)
{
part, err := w.CreateFormFile("myfile", "my-file.txt")
if err != nil {
t.Fatalf("CreateFormFile: %v", err)
}
part.Write(fileContents)
err = w.WriteField("key", "val") // <---- here!
if err != nil {
t.Fatalf("WriteField: %v", err)
}
part.Write([]byte("val"))
....
Reference :
Advertisement
Something interesting
Tutorials
+8.9k Golang : HTTP Routing with Goji example
+32.5k Golang : Math pow(the power of x^y) example
+6.7k Golang : Skip or discard items of non-interest when iterating example
+40.6k Golang : Convert to io.ReadSeeker type
+62.8k Golang : Convert HTTP Response body to string
+9.5k Android Studio : Indicate progression with ProgressBar example
+5.8k Golang : Struct field tags and what is their purpose?
+17.1k Golang : XML to JSON example
+4.5k Java : Generate multiplication table example
+14.7k Golang : Send email with attachment(RFC2822) using Gmail API example
+18k Golang : How to make a file read only and set it to writable again?
+5.8k Linux : Disable and enable IPv4 forwarding