I tried to act like a question using the filepath.Wark
function.
var paths []string
err := os.Chdir("C:\\")
if err != nil {
return err
}
err = filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
matched, err := filepath.Match(extension /*"*.reg"*/, info.Name())
if err != nil {
return err
}
if matched {
paths = append(paths, path)
}
}
return nil
})
if err != nil {
return err
}
41 reg files were found this way, but using the everything program, 103 reg files were found.
I want to have 103 results. First of all, I checked that reg file exists not only in Program Files but also in the Users folder, but not found in go.
I ran admin permission.
I would suggest using filepath.Ext to find the extension of the file, lowercase it and test equality with .reg
. That would be a better way for just extensions.
Another reason could be that you might not have permissions to browse other users' directory in Users directory. Try running the program as administrator.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments