Last active
August 29, 2015 14:04
-
-
Save yyuu/c5f9d04f3dae2997e625 to your computer and use it in GitHub Desktop.
A utility to test Go's filepath.Match to write .dockerignore
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" | |
"os" | |
"path/filepath" | |
) | |
func main() { | |
if len(os.Args) < 2 { | |
fmt.Fprintf(os.Stderr, "missing operand") | |
os.Exit(1) | |
} | |
pattern := os.Args[1] | |
names := os.Args[2:] | |
for _, name := range names { | |
matched, err := filepath.Match(pattern, name) | |
if err != nil { panic(err) } | |
if ! matched { | |
fmt.Printf("! %s\n", name) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment