Golang bytes.Buffer.Write() function example
package bytes
Write appends the contents of the given input to the buffer, growing the buffer as needed. The return value n is the length of p; err is always nil. If the buffer becomes too large, Write will panic with ErrTooLarge.
Golang bytes.Buffer.Write() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
buff := bytes.NewBuffer(nil) // create empty buffer
n, err := buff.Write([]byte("abc"))
fmt.Printf("%s %d %v \n", string(buff.Bytes()), n, err)
}
Output :
abc 3 <nil>
Reference :
Advertisement
Something interesting
Tutorials
+8.3k Golang : Count leading or ending zeros(any item of interest) example
+36k Golang : Get file last modified date and time
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+6.9k Golang : Decode XML data from RSS feed
+8.3k Golang : Check if integer is power of four example
+15.4k Golang : Find location by IP address and display with Google Map
+19.1k Golang : Display list of time zones with GMT
+4.6k Linux : sudo yum updates not working
+12.3k Golang : Get month name from date example
+9.7k Golang : Populate slice with sequential integers example
+13.9k Golang : Get dimension(width and height) of image file
+9.9k Golang : Ordinal and Ordinalize a given number to the English ordinal numeral