Created
October 9, 2018 00:31
-
-
Save rfay/0b1ceef27ec8bf8ae9dd9f54f94428f4 to your computer and use it in GitHub Desktop.
This file contains 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 main | |
import ( | |
"fmt" | |
"path/filepath" | |
) | |
func main() { | |
matches, _ := checkForFileInSubdirs(".", "junk.txt") | |
fmt.Printf("Matches for 'junk.txt: %v\n", matches) | |
matches, _ = checkForFileInSubdirs(".", "lookingnotfinding.txt") | |
fmt.Printf("Matches for 'lookingnotfinding.txt: %v\n", matches) | |
} | |
// checkForFileInSubdirs returns an array of found files in subdir | |
func checkForFileInSubdirs(path string, fileName string) ([]string, error) { | |
glob := path + "/*/" + fileName | |
matches, err := filepath.Glob(glob) | |
return matches, err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment