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
+9.6k Golang : Sort and reverse sort a slice of floats
+13.2k Golang : Skip blank/empty lines in CSV file and trim whitespaces example
+7.1k Golang : Get Alexa ranking data example
+12k Golang : Find and draw contours with OpenCV example
+6.9k Golang : Fibonacci number generator examples
+17.9k Golang : How to make a file read only and set it to writable again?
+6.1k Golang : Get missing location after unmarshal binary and gob decode time.
+10.8k Android Studio : Checkbox for user to select options example
+5.7k Get website traffic ranking with Similar Web or Alexa
+13.7k Golang : Tutorial on loading GOB and PEM files
+10.7k Golang : Underscore string example
+5.2k Golang : Calculate half life decay example