package main import "io" import "log" import "os" var reader io.Reader func main() { if len(os.Args) <= 1 { reader = os.Stdin } else { readers := []io.Reader{} for _, fname := range os.Args[1:] { if f, err := os.Open(fname); err != nil { log.Fatalln(err) } else { defer f.Close() readers = append(readers, f) } } reader = io.MultiReader(readers...) } io.Copy(os.Stdout, reader) }