42 lines
734 B
Go
42 lines
734 B
Go
|
package osutils
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
func IsDirectory(path string) (bool, error) {
|
||
|
fileInfo, err := os.Stat(path)
|
||
|
if err != nil {
|
||
|
return false, err
|
||
|
}
|
||
|
|
||
|
return fileInfo.IsDir(), err
|
||
|
}
|
||
|
|
||
|
func RecursiceWalk(pathToWalk string) ([]string, error) {
|
||
|
paths := []string{}
|
||
|
err := filepath.Walk(pathToWalk,
|
||
|
func(path string, info os.FileInfo, err error) error {
|
||
|
if err != nil {
|
||
|
println(err)
|
||
|
return err
|
||
|
}
|
||
|
// fmt.Println(path[len(path)-4:])
|
||
|
libBool, err := IsDirectory(path)
|
||
|
if err != nil {
|
||
|
println("error in checking lib or dir")
|
||
|
}
|
||
|
if !libBool {
|
||
|
// println(path)
|
||
|
paths = append(paths, path)
|
||
|
}
|
||
|
return nil
|
||
|
})
|
||
|
if err != nil {
|
||
|
log.Println(err)
|
||
|
}
|
||
|
return paths, nil
|
||
|
}
|