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
+5.9k Golang : Normalize email to prevent multiple signups example
+18.3k Golang : Close channel after ticker stopped example
+11.7k Generate salted password with OpenSSL example
+4.7k Golang : Grab news article text and use NLP to get each paragraph's sentences
+9.7k Golang : Fix - does not implement sort.Interface (missing Len method)
+4.4k Golang : If else example and common mistake
+3.6k Adding Skype actions such as call and chat into web page examples
+8.2k Golang : Scramble and unscramble text message by randomly replacing words
+5.5k Golang : Combine slices of complex numbers and operation example
+7.9k Golang : Populate or initialize struct with values example
+4.1k Swift : Convert (cast) Float to Int or Int32 value
+18.3k Golang : Determine if directory is empty with os.File.Readdir() function