Golang bufio.Reset() function example
package bufio
Reset discards any buffered data, resets all state, and switches the buffered reader to read new input
Golang bufio.Reset() function usage example
readbuffer := bytes.NewBuffer([]byte("abcde#fghijk"))
reader := bufio.NewReader(readbuffer)
before, _ := reader.ReadString('#') // # is the delimiter
fmt.Println(string(before))
reader.Reset(readbuffer)
after, _ := reader.ReadString('#')
fmt.Println(string(after))
Output :
abcde#
_______
Note: _______ means empty spaces
Reference :
Advertisement
Something interesting
Tutorials
+11.5k Golang : Get terminal width and height example
+3.5k Javascript : How to show different content with noscript?
+19.2k Golang : Pipe output from one os.Exec(shell command) to another command
+10.7k Golang : Clean formatting/indenting or pretty print JSON result
+28.7k Get client IP Address in Go
+26k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+13.1k Golang : How to determine if user agent is a mobile device example
+8.1k Golang : How to check if a string with spaces in between is numeric?
+16.5k Golang : Put UTF8 text on OpenCV video capture image frame
+11k Golang : 2 dimensional array example
+7.9k Golang : Get SPF and DMARC from email headers to fight spam
+16.1k Golang : delete and modify XML file content