Golang bytes.Buffer.WriteRune() function example
package bytes
WriteRune appends the UTF-8 encoding of Unicode code point input rune to the buffer, returning its length and an error, which is always nil but is included to match bufio.Writer's WriteRune. The buffer is grown as needed; if it becomes too large, WriteRune will panic with ErrTooLarge.
Golang bytes.Buffer.WriteRune() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
buff := bytes.NewBuffer(nil) // create empty buffer
n, err := buff.WriteRune('世')
fmt.Printf("%s %d %v \n", string(buff.Bytes()), n, err)
}
Output :
世 3 <nil>
Reference :
Advertisement
Something interesting
Tutorials
+39.6k Golang : Remove dashes(or any character) from string
+7.4k Golang : Example of custom handler for Gorilla's Path usage.
+10.6k Golang : Resolve domain name to IP4 and IP6 addresses.
+16.4k Golang : How to implement two-factor authentication?
+16.3k Golang : How to extract links from web page ?
+9.7k Golang : Populate slice with sequential integers example
+13.7k Golang : Check if an integer is negative or positive
+20.7k Golang : Read directory content with os.Open
+10.5k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine
+10.5k Generate Random number with math/rand in Go
+26.7k Golang : How to check if a connection to database is still alive ?
+30.6k Golang : Remove characters from string example