Golang bufio.ReadString() function example
package bufio
ReadString reads until the first occurrence of delimiter in the input, returning a string containing the data up to and including the delimiter. If ReadString encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadString returns err != nil if and only if the returned data does not end in delimiter. For simple uses, a Scanner may be more convenient.
Golang bufio.ReadString() function usage example
readbuffer := bytes.NewBuffer([]byte("abcde#fghijk"))
reader := bufio.NewReader(readbuffer)
str,_ := reader.ReadString('#') // # is the delimiter
fmt.Println(string(str))
Output :
abcde#
Reference :
Advertisement
Something interesting
Tutorials
+8.6k Golang : Add text to image and get OpenCV's X, Y co-ordinates example
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+22.4k Golang : How to read JPG(JPEG), GIF and PNG files ?
+21.8k Golang : Convert string slice to struct and access with reflect example
+17.2k Golang : Find file size(disk usage) with filepath.Walk
+9.4k Golang : Create unique title slugs example
+17.6k Golang : Upload/Receive file progress indicator
+13.9k Golang : Get dimension(width and height) of image file
+9.2k Golang : Create and shuffle deck of cards example
+10.3k Golang : Convert file content to Hex
+6.8k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+13.7k Golang : Tutorial on loading GOB and PEM files