Golang bufio.ScanBytes() function example
package bufio
ScanBytes is a split function for a Scanner that returns each byte as a token.
bufio.ScanBytes() function usage example
file, err := os.Open("for")
if err != nil {
panic(err.Error())
}
defer file.Close()
reader := bufio.NewReader(file)
scanner := bufio.NewScanner(reader)
scanner.Split(bufio.ScanBytes)
for scanner.Scan() {
fmt.Println(scanner.Bytes())
}
Advertisement
Something interesting
Tutorials
+7k Golang : Levenshtein distance example
+17k Golang : Capture stdout of a child process and act according to the result
+17.2k Golang : When to use init() function?
+9.1k Golang : Intercept and compare HTTP response code example
+12.2k Golang : Get remaining text such as id or filename after last segment in URL path
+16.6k Golang : Delete files by extension
+11.3k Golang : How to flush a channel before the end of program?
+5.4k How to check with curl if my website or the asset is gzipped ?
+4.6k MariaDB/MySQL : How to get version information
+11.8k Golang : Verify Linux user password again before executing a program example
+8.8k Golang : Heap sort example
+10.1k Golang : Find and replace data in all files recursively