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
+5k Python : Convert(cast) bytes to string example
+25.6k Golang : convert rune to integer value
+11.1k Golang : Fix go.exe is not compatible with the version of Windows you're running
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+6.8k Golang : Find the longest line of text example
+5.8k Javascript : How to replace HTML inside <div>?
+5.6k PHP : Fix Call to undefined function curl_init() error
+6.9k Nginx : Password protect a directory/folder
+7.9k Golang : Ways to recover memory during run time.
+10.1k Golang : Print how to use flag for your application example
+30.4k Golang : How to redirect to new page with net/http?