Golang bufio.ReadLine() function example
package bufio
ReadLine tries to return a single line, not including the end-of-line bytes.
Golang bufio.ReadLine() function usage example
readbuffer := bytes.NewBuffer([]byte("123\r\n456"))
reader := bufio.NewReader(readbuffer)
line, prefix, err := reader.ReadLine()
if err == nil {
fmt.Printf("%v, %s, %v\n", line, string(line), prefix)
}
output :
[49 50 51], 123, false
Reference :
Advertisement
Something interesting
Tutorials
+4.7k Javascript : Access JSON data example
+15.6k Golang : Validate hostname
+7.7k Golang : get the current working directory of a running program
+30.6k Get client IP Address in Go
+12.7k Golang : Get absolute path to binary for os.Exec function with exec.LookPath
+15.3k Golang : Save(pipe) HTTP response into a file
+39.1k Golang : How to iterate over a []string(array)
+6.1k Golang : Experimenting with the Rejang script
+5.3k Python : Create Whois client or function example
+7.5k Golang : Gorrila set route name and get the current route name
+7.9k Golang : Example of how to detect which type of script a word belongs to
+41.1k Golang : How to check if a string contains another sub-string?