Created
June 15, 2024 11:50
-
-
Save sullemanhossam/39052ab833b0e3817971c0cc445df6a2 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
package repominer | |
// this package should go insidde a filepath and get all the relative paths | |
import ( | |
"fmt" | |
"io/fs" | |
"os" | |
"path/filepath" | |
) | |
func RepoMiner() { | |
// Define the absolute path | |
absolutePath, err := filepath.Abs(".") | |
if err != nil { | |
fmt.Println("Error:", err) | |
return | |
} | |
err = WalkDir(os.DirFS(absolutePath), ".", func(path string, d fs.DirEntry, err error) error { | |
if err != nil { | |
return err | |
} | |
// Print the full path by combining the absolute path with the relative path | |
fullPath := filepath.Join(absolutePath, path) | |
fmt.Println(fullPath) | |
return nil | |
}) | |
if err != nil { | |
fmt.Println("Error:", err) | |
} | |
} | |
func WalkDir(fsys fs.FS, root string, fn fs.WalkDirFunc) error { | |
return fs.WalkDir(fsys, root, fn) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment