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
+5.8k Golang : Find change in a combination of coins example
+11.9k Golang : Determine if time variables have same calendar day
+5.4k How to check with curl if my website or the asset is gzipped ?
+8k Findstr command the Grep equivalent for Windows
+16.8k Golang : Read integer from file into array
+7.8k Golang : Load DSA public key from file example
+8.8k Golang : Gorilla web tool kit schema example
+7.2k CloudFlare : Another way to get visitor's real IP address
+19.7k Golang : Archive directory with tar and gzip
+7.5k Golang : Process json data with Jason package
+20.6k Golang : Secure(TLS) connection between server and client