trying_out_go/cmd/playground/directory.go

29 lines
404 B
Go
Raw Permalink Normal View History

package main
import (
"fmt"
"os"
"path/filepath"
)
func scanDirectory(path string) {
fmt.Println(path)
files, err := os.ReadDir(path)
if err != nil {
panic(err)
}
for _, file := range files {
filePath := filepath.Join(path, file.Name())
if file.IsDir() {
scanDirectory(filePath)
} else {
fmt.Println(filePath)
}
}
}
func directory() {
scanDirectory("../../trying_out_go")
}