Skip to content

Instantly share code, notes, and snippets.

@sullemanhossam
Created June 15, 2024 11:50
Show Gist options
  • Save sullemanhossam/39052ab833b0e3817971c0cc445df6a2 to your computer and use it in GitHub Desktop.
Save sullemanhossam/39052ab833b0e3817971c0cc445df6a2 to your computer and use it in GitHub Desktop.
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