Looking for go Answers? Try Ask4KnowledgeBase
Looking for go Keywords? Try Ask4Keywords

Go Listing all the files and folders in the current directory


Example

package main

import (
    "fmt"
    "io/ioutil"
)

func main() {
    files, err := ioutil.ReadDir(".")
    if err != nil {
        panic(err)
    }

    fmt.Println("Files and folders in the current directory:")

    for _, fileInfo := range files {
        fmt.Println(fileInfo.Name())
    }
}