ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.
package main import ( "fmt" "io/ioutil" "log" ) func main() { files, err := ioutil.ReadDir(".") if err != nil { log.Fatal(err) } for _, file := range files { fmt.Println(file.Name()) } }