now can also read from stdin
This commit is contained in:
parent
8a2c4757b9
commit
18d362c926
@ -68,9 +68,16 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
filename := os.Args[1]
|
||||
|
||||
file, _ := os.Open(filename)
|
||||
var file *os.File
|
||||
if filename != "-" {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer file.Close()
|
||||
} else {
|
||||
file = os.Stdin
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
lineno := 0
|
||||
|
Loading…
Reference in New Issue
Block a user