Wrote a simple program that calls "ls", then passes each line through regexp filtering for files that end in an "s". ls is used only for the purposes of learning the exec package. How can I improve the code below to be more correct/succinct/go-ish?
package main
import (
"bufio"
"fmt"
"os/exec"
"regexp"
)
func main() {
cmd := exec.Command("ls")
stdout, _ := cmd.StdoutPipe()
s := bufio.NewReader(stdout)
cmd.Start()
go cmd.Wait()
for {
l, _, err := s.ReadLine()
if err != nil {
break
}
if m, err := regexp.Match(".*s$", l); m && err == nil {
fmt.Println(string(l))
}
}
}