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
+51.5k Golang : Check if item is in slice/array
+30.9k error: trying to remove "yum", which is protected
+5.9k Golang : List all packages and search for certain package
+7.6k Golang : Detect sample rate, channels or latency with PortAudio
+9.8k Golang : Format strings to SEO friendly URL example
+14.3k Golang : Chunk split or divide a string into smaller chunk example
+10.9k PHP : Convert(cast) bigInt to string
+4.8k JavaScript: Add marker function on Google Map
+6.2k Linux/Unix : Commands that you need to be careful about
+13.5k Golang : Get constant name from value
+9k Golang : Populate or initialize struct with values example
+18.3k Golang : Get command line arguments