Golang bytes.Buffer.WriteByte() function example
package bytes
WriteByte appends the input byte to the buffer, growing the buffer as needed. The returned error is always nil, but is included to match bufio.Writer's WriteByte. If the buffer becomes too large, WriteByte will panic with ErrTooLarge.
Golang bytes.Buffer.WriteByte() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
buff := bytes.NewBuffer(nil) // create empty buffer
buff.WriteByte('a')
buff.WriteRune('中')
buff.WriteByte('b')
fmt.Printf("%s \n", string(buff.Bytes()))
}
Output :
a中b
Reference :
Advertisement
Something interesting
Tutorials
+15k Golang : Search folders for file recursively with wildcard support
+8.9k Golang : GMail API create and send draft with simple upload attachment example
+16.4k Golang : Test floating point numbers not-a-number and infinite example
+16k Golang : Read large file with bufio.Scanner cause token too long error
+12.3k Golang : Get month name from date example
+19.9k Golang : Accept input from user with fmt.Scanf skipped white spaces and how to fix it
+10.4k Golang : Meaning of omitempty in struct's field tag
+9.7k Golang : Format strings to SEO friendly URL example
+6.3k Unix/Linux : Use netstat to find out IP addresses served by your website server
+16.3k Golang : How to extract links from web page ?
+48.1k Golang : How to convert JSON string to map and slice
+6.5k Golang : Combine slices of complex numbers and operation example