Golang bufio.NewScanner() function example
package bufio
NewScanner returns a new Scanner to read from. The split function defaults to ScanLines.
Golang bufio.NewScanner() function usage example
package main
import (
"fmt"
"os"
"bufio"
)
func main () {
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
+5.6k PHP : Fix Call to undefined function curl_init() error
+12.7k Golang : Drop cookie to visitor's browser and http.SetCookie() example
+8.8k Golang : Executing and evaluating nested loop in html template
+12k Golang : How to parse plain email text and process email header?
+32.3k Golang : Validate email address with regular expression
+16.5k Golang : Convert slice to array
+21.6k Golang : How to read float value from standard input ?
+18.5k Golang : How to remove certain lines from a file
+15.4k nginx: [emerg] unknown directive "ssl"
+9.6k Golang : Get all countries currencies code in JSON format
+18k Golang : Defer function inside init()
+18.1k Golang : Check if a directory exist or not