Name: Anonymous 2015-07-30 9:03
All languages should just be syntactic sugar for an intermediate language that's mature enough to have optimizing compilers
package main
import (
"errors"
"flag"
"io"
"os"
)
func check(err error) {
if err != nil {
panic(err)
}
}
func main() {
var uFlag *bool = flag.Bool("u", false, "Write bytes from the input file to the standard output without delay as each is read.")
flag.Parse()
if *uFlag {
panic(errors.New("Not implemented"))
}
files := flag.Args()
if len(files) == 0 || files[0] == "-" {
// stdin -> stdout mode
io.Copy(os.Stdout, os.Stdin)
} else {
// file mode
for _, file := range files {
f, err := os.Open(file);
check(err)
defer f.Close()
io.Copy(os.Stdout, f)
}
}
}