Read directory
This is an example Go program for read-directory.
package main import ( "fmt" "os" ) func main() { dir := "." entries, err := os.ReadDir(dir) if err != nil { fmt.Fprintf(os.Stderr, "Fatal error reading %s: %s\n", dir, err) os.Exit(1) } for _, entry := range entries { fmt.Printf("%s\n", entry.Name()) } }
The output of the example looks like this:
.gitignore index.html links-table makefile rd rd.go rd.go.~1~ rd.txt tags
Copyright © Ben Bullock 2009-2024. All
rights reserved.
For comments, questions, and corrections, please email
Ben Bullock
(benkasminbullock@gmail.com).
/
Privacy /
Disclaimer