go-cat2 improve args loop

This commit is contained in:
Meutel 2017-07-07 17:13:07 +02:00
parent 0433c6344c
commit d4ce506f26

View File

@ -43,8 +43,8 @@ func main() {
reader = strings.NewReader(content)
} else {
readers := []io.Reader{}
for i := 1; i < len(os.Args); i++ {
f := openFile(&os.Args[i])
for _, fname := range os.Args[1:] {
f := openFile(&fname)
defer f.Close()
readers = append(readers, f)
}