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
+5.9k AWS S3 : Prevent Hotlinking policy
+7.8k Swift : Convert (cast) String to Double
+17.5k Golang : Linked list example
+10.6k Golang : Simple File Server
+12.3k Golang : How to check if a string starts or ends with certain characters or words?
+22.7k Golang : Strings to lowercase and uppercase example
+5.9k Golang : Detect variable or constant type
+46.5k Golang : Marshal and unmarshal json.RawMessage struct example
+8.4k Golang : Ackermann function example
+8.5k Golang : How to check variable or object type during runtime?
+5.6k Golang : Detect words using using consecutive letters in a given string
+16k Golang : How to reverse elements order in map ?