Golang bufio.UnreadByte() function example
package bufio
UnreadByte unreads the last byte. Only the most recently read byte can be unread.
Golang bufio.UnreadByte() function usage example
readbuffer := bytes.NewBuffer([]byte("abcde#fghijk"))
reader := bufio.NewReader(readbuffer)
before, _ := reader.ReadString('#') // # is the delimiter
fmt.Println(string(before))
reader.UnreadByte() // move the reader position back by 1 byte
after, _ := reader.ReadString('#')
fmt.Println(string(after))
Output :
abcde#
#
Advertisement
Something interesting
Tutorials
+15.3k Golang : Get query string value on a POST request
+5.1k Linux/Unix/MacOSX : Find out which application is listening to port 80 or use which IP version
+17.6k Convert JSON to CSV in Golang
+5.6k Unix/Linux : How to find out the hard disk size?
+8k Golang : Handle Palindrome string with case sensitivity and unicode
+7.8k Golang : Getting Echo framework StartAutoTLS to work
+7.7k Golang : get the current working directory of a running program
+7.5k Gogland : Single File versus Go Application Run Configurations
+11.3k Golang : How to flush a channel before the end of program?
+7.5k SSL : How to check if current certificate is sha1 or sha2 from command line
+30.4k Golang : How to verify uploaded file is image or allowed file types
+5.9k Facebook : How to force facebook to scrape latest URL link data?