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
+7.1k CloudFlare : Another way to get visitor's real IP address
+5.7k Unix/Linux : How to test user agents blocked successfully ?
+7.2k Golang : Of hash table and hash map
+20.6k Golang : Read directory content with os.Open
+40.9k Golang : How to check if a string contains another sub-string?
+23.8k Golang : Use regular expression to validate domain name
+10.5k Golang : Select region of interest with mouse click and crop from image
+20.8k Golang : Underscore or snake_case to camel case example
+22.1k Golang : Print leading(padding) zero or spaces in fmt.Printf?
+5.4k Golang *File points to a file or directory ?
+7.3k Golang : Example of custom handler for Gorilla's Path usage.