Golang bytes.Buffer.ReadString() function example
package bytes
ReadString reads until the first occurrence of delimiter(1st parameter) 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.
Golang bytes.Buffer.ReadString() function usage
package main
import (
"bytes"
"fmt"
)
func main() {
buff := bytes.NewBuffer([]byte("abcde#fg"))
line, err := buff.ReadString('#')
fmt.Println(line,err)
}
Output :
abcde# <nil>
Reference :
Advertisement
Something interesting
Tutorials
+6k Golang : Compound interest over time example
+11.6k Golang : Fuzzy string search or approximate string matching example
+14.2k Golang : Convert IP version 6 address to integer or decimal number
+14.5k Golang : How to check if your program is running in a terminal
+8.8k Android Studio : Image button and button example
+16.5k Golang : Check if a string contains multiple sub-strings in []string?
+16.3k Golang :Trim white spaces from a string
+13.5k Golang : How to get year, month and day?
+5.1k Golang : Display packages names during compilation
+10.6k Golang : Get local time and equivalent time in different time zone
+5k Golang : micron to centimeter example
+16.1k Golang : Generate universally unique identifier(UUID) example