Created
September 7, 2020 20:45
-
-
Save LandonTClipp/a933c2530df437a1d6cfea8ec77de098 to your computer and use it in GitHub Desktop.
github.com/chigopher/pathlib os example
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
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/chigopher/pathlib" | |
) | |
func main() { | |
// Create a path on your regular OS filesystem | |
path := pathlib.NewPath("/") | |
subdirs, err := path.ReadDir() | |
if err != nil { | |
fmt.Printf("%v\n", err) | |
os.Exit(1) | |
} | |
for _, dir := range subdirs { | |
fmt.Println(dir.Name()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment