How do I use bufio for buffered IO in Go?

go, bufio, buffered io
This example demonstrates how to use the bufio package in Go for efficient buffered IO operations.
package main import ( "bufio" "fmt" "os" ) func main() { // Open the file file, err := os.Open("example.txt") if err != nil { fmt.Println(err) return } defer file.Close() // Create a new buffered reader reader := bufio.NewReader(file) // Read the file line by line for { line, err := reader.ReadString('\n') if err != nil { break } fmt.Print(line) } }

go bufio buffered io