Last active
April 26, 2021 03:18
-
-
Save Ramko9999/bfa8b6f692e794773dfd1b02ee595496 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"fmt" | |
"log" | |
"os" | |
) | |
/* | |
Suppose this was the directory structure of test: | |
- test | |
- a.txt | |
- b | |
- c.txt | |
getDirectoryContents will print out "a.txt" and "b". | |
*/ | |
func getDirectoryContents(){ | |
entries, err := os.ReadDir("./test"); | |
if err != nil { | |
log.Fatal(err); | |
} | |
//iterate through the directory entities and print out their name. | |
for _, entry := range(entries) { | |
fmt.Println(entry.Name()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment