title: How do you get full paths of all files in a directory in Go?
body: <p>I am using Go to iterate over all the files in a directory. This is how I am doing it:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "io/ioutil"
  )
  
  func main() {
      printFiles(".")
  }
  
  func printFiles(dir string) {
      fileInfos, err := ioutil.ReadDir(dir)
      if err != nil {
          fmt.Println("Error in accessing directory:", err)
      }
  
      for _, file := range fileInfos {
          fmt.Printf("%T: %+v\n", file, file)
      }
  }
  </code></pre>
  
  <p>When I run this code, this is the output I get:</p>
  
  <pre><code>*os.fileStat: &amp;{name:main.go sys:{FileAttributes:32 CreationTime:{LowDateTime:2993982878 HighDateTime:30613689} LastAccessTime:{LowDateTime:2993982878 HighDateTime:30613689} LastWriteTime:{LowDateTime:4004986069 HighDateTime:30613714} FileSizeHigh:0 FileSizeLow:320} pipe:false Mutex:{state:0 sema:0} path:C:\Users\Prakhar.Mishra\go\src\mistdatafilter\main.go vol:0 idxhi:0 idxlo:0}
  </code></pre>
  
  <p>I can see a property named <strong>path</strong>, but I can't access it (due to small case initial, I suppose?). Can anyone please tell me how to get full file path of all the files in a given folder?</p>