Created
February 18, 2020 19:22
-
-
Save juliakm/47584fb0dfe2461dd7ef28007d5cb5a4 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 main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"path/filepath" | |
"strings" | |
) | |
func visit(files *[]string) filepath.WalkFunc { | |
return func(path string, info os.FileInfo, err error) error { | |
if err != nil { | |
log.Fatal(err) | |
} | |
if strings.Contains(path, "includes") { | |
*files = append(*files, path) | |
} | |
return nil | |
} | |
} | |
func main() { | |
var files []string | |
root := "/my/file/path/azure-devops-docs-pr/docs/pipelines" | |
err := filepath.Walk(root, visit(&files)) | |
if err != nil { | |
panic(err) | |
} | |
for _, file := range files { | |
fmt.Println(file) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment