mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-24 02:36:15 +00:00
26 lines
438 B
Go
26 lines
438 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
filename := os.Args[1]
|
|
|
|
handle, err := os.Open(filename)
|
|
if err != nil {
|
|
fmt.Println("OERR", err)
|
|
os.Exit(1)
|
|
}
|
|
defer handle.Close()
|
|
|
|
scanner := bufio.NewScanner(handle)
|
|
for scanner.Scan() {
|
|
fmt.Println(scanner.Text()) // Println will add back the final '\n'
|
|
}
|
|
if err := scanner.Err(); err != nil {
|
|
fmt.Fprintln(os.Stderr, "reading standard input:", err)
|
|
}
|
|
}
|