1
0
Fork 1
mirror of https://github.com/vbatts/tar-split.git synced 2024-11-16 13:28:37 +00:00

Merge pull request #19 from stephen679/check_valid_keyword

check: error out on unrecognized keyword
This commit is contained in:
Vincent Batts 2016-07-15 11:08:20 +09:00 committed by GitHub
commit 818b9227d7

View file

@ -63,13 +63,13 @@ func Check(root string, dh *DirectoryHierarchy, keywords []string) (*Result, err
} }
for _, kv := range kvs { for _, kv := range kvs {
if keywords != nil && !inSlice(kv.Keyword(), keywords) {
continue
}
keywordFunc, ok := KeywordFuncs[kv.Keyword()] keywordFunc, ok := KeywordFuncs[kv.Keyword()]
if !ok { if !ok {
return nil, fmt.Errorf("Unknown keyword %q for file %q", kv.Keyword(), e.Path()) 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) curKeyVal, err := keywordFunc(filepath.Join(root, e.Path()), info)
if err != nil { if err != nil {
return nil, err return nil, err