Golang mime/multipart.SetBoundary() function example
package mime/multipart
Golang mime/multipart.SetBoundary() function usage example
var b bytes.Buffer
w := NewWriter(&b)
err := w.SetBoundary(strings.Repeat("x", 69))
if err != nil {
panic(err)
}
By default, the boundary are set by this function
func randomBoundary() string {
var buf [30]byte
_, err := io.ReadFull(rand.Reader, buf[:])
if err != nil {
panic(err)
}
return fmt.Sprintf("%x", buf[:])
}
but you can generate the boundary by your own, then you get the header for CreatePart, call NewWriter, and set the boundary by calling multipart.Writer.SetBoundary.
Reference :
Advertisement
Something interesting
Tutorials
+51.3k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+13.8k Golang : Check if an integer is negative or positive
+9.1k Golang : Get SPF and DMARC from email headers to fight spam
+12.8k Golang : Listen and Serve on sub domain example
+16.3k Golang : convert string or integer to big.Int type
+9.9k Golang : Sort and reverse sort a slice of integers
+5.1k Golang : Check if a word is countable or not
+5.5k Golang : If else example and common mistake
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+7.4k Golang : How to iterate a slice without using for loop?
+15.9k Golang : Get digits from integer before and after given position example
+18.8k Golang : convert int to string