Skip to content

Instantly share code, notes, and snippets.

@yyuu
Last active August 29, 2015 14:04
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 yyuu/c5f9d04f3dae2997e625 to your computer and use it in GitHub Desktop.
Save yyuu/c5f9d04f3dae2997e625 to your computer and use it in GitHub Desktop.
A utility to test Go's filepath.Match to write .dockerignore
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