30 lines
459 B
Go
30 lines
459 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
// "io"
|
|
"io/ioutil"
|
|
"log"
|
|
// "bufio"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
var usage = "usage: splitter [file]"
|
|
|
|
func main() {
|
|
var of *os.File
|
|
var err error
|
|
if len(os.Args) == 2 {
|
|
filename := os.Args[1]
|
|
of, err = os.Open(filename)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
} else {
|
|
of = os.Stdin
|
|
}
|
|
b, err := ioutil.ReadAll(of)
|
|
fmt.Printf("%v\n", strings.Fields(string(b)))
|
|
}
|