From d06c91220fc644e560e3852e93fff6834b80bc46 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Thu, 14 Jul 2016 12:21:47 -0400 Subject: [PATCH] check: error out on unrecognized keyword Make sure a keyword is valid before checking if the keyword exists in the set of KeyVals that Check() is supposed to validate. Signed-off-by: Stephen Chung --- check.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check.go b/check.go index 44c0ea2..25ee07b 100644 --- a/check.go +++ b/check.go @@ -63,13 +63,13 @@ func Check(root string, dh *DirectoryHierarchy, keywords []string) (*Result, err } for _, kv := range kvs { - if keywords != nil && !inSlice(kv.Keyword(), keywords) { - continue - } keywordFunc, ok := KeywordFuncs[kv.Keyword()] if !ok { return nil, fmt.Errorf("Unknown keyword %q for file %q", kv.Keyword(), e.Path()) } + if keywords != nil && !inSlice(kv.Keyword(), keywords) { + continue + } curKeyVal, err := keywordFunc(filepath.Join(root, e.Path()), info) if err != nil { return nil, err