Skip to content

Instantly share code, notes, and snippets.

@rfay
Created October 9, 2018 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfay/0b1ceef27ec8bf8ae9dd9f54f94428f4 to your computer and use it in GitHub Desktop.
Save rfay/0b1ceef27ec8bf8ae9dd9f54f94428f4 to your computer and use it in GitHub Desktop.
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