Golang bytes.Buffer.Reset() function example
package bytes
Reset resets the buffer so it has no content. Buffer.Reset() is the same as Buffer.Truncate(0).
Golang bytes.Buffer.Reset() function usage example
package main
import (
"bytes"
"fmt"
)
func main() {
buff := bytes.NewBuffer([]byte("abcdefg"))
fmt.Printf("%d \n", buff.Len())
// remove all content from the buff buffer
buff.Reset()
fmt.Printf("%d \n", buff.Len())
}
Output :
7
0
Reference :
Advertisement
Something interesting
Tutorials
+7.4k Golang : Check to see if *File is a file or directory
+10.1k Golang : Test a slice of integers for odd and even numbers
+5.8k Golang : Find change in a combination of coins example
+48.1k Golang : How to convert JSON string to map and slice
+8.2k Android Studio : Rating bar example
+38.1k Golang : Read a text file and replace certain words
+8.5k Linux/Unix : fatal: the Postfix mail system is already running
+6.3k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+6k PHP : How to check if an array is empty ?
+9.6k Golang : Copy map(hash table) example
+6.7k Golang : Output or print out JSON stream/encoded data
+6.8k Golang : Get expvar(export variables) to work with multiplexer