mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 18:25:45 +00:00
32 lines
434 B
Go
32 lines
434 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()
|
|
|
|
lineReader := bufio.NewReader(handle)
|
|
|
|
eof := false
|
|
for !eof {
|
|
|
|
line, err := lineReader.ReadString('\n') // TODO: auto-detect
|
|
if err != nil {
|
|
if line != "" {
|
|
fmt.Println(line)
|
|
}
|
|
break
|
|
}
|
|
fmt.Print(line)
|
|
}
|
|
}
|