title: Getting count of files in directory using Go
body: <p>How might I get the count of items returned by io/ioutil.ReadDir()?</p>
  
  <p>I have this code, which works, but I have to think isn't the RightWay(tm) in Go.    </p>
  
  <pre><code>package main
  
  import "io/ioutil"
  import "fmt"
  
  func main() {
      files,_ := ioutil.ReadDir("/Users/dgolliher/Dropbox/INBOX")
      var count int
      for _, f := range files {
          fmt.Println(f.Name())
          count++
      }
      fmt.Println(count)
  }
  </code></pre>
  
  <p>Lines 8-12 seem like way too much to go through to just count the results of ReadDir, but I can't find the correct syntax to get the count without iterating over the range.  Help?</p>