Golang bufio.ReadBytes() function example
package bufio
ReadBytes reads until the first occurrence of delimiter in the input, returning a slice containing the data up to and including the delimiter. If ReadBytes encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadBytes 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.ReadBytes() function usage example
readbuffer := bytes.NewBuffer([]byte("abcd#fg"))
reader := bufio.NewReader(readbuffer)
buffer, err := reader.ReadBytes('#') // # is our delimiter
fmt.Printf("%s \n", string(buffer))
Output :
abcd
Advertisement
Something interesting
Tutorials
+26.4k Golang : Convert(cast) string to uint8 type and back to string
+8.1k Golang : Randomize letters from a string example
+12.5k Golang : HTTP response JSON encoded data
+13.6k Golang : Query string with space symbol %20 in between
+10.9k Golang : Removes punctuation or defined delimiter from the user's input
+10.8k PHP : Convert(cast) bigInt to string
+10.9k Golang : Sieve of Eratosthenes algorithm
+20.2k Golang : How to get struct tag and use field name to retrieve data?
+16.4k Golang : Send email and SMTP configuration example
+5.4k Unix/Linux : How to archive and compress entire directory ?
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+9.5k Golang : Changing a RGBA image number of channels with OpenCV