From b426c20e1494f2c0868673795532b84a0353ced8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 30 Jul 2016 22:32:03 +0200 Subject: [PATCH] Return specific error on walk path too short --- helpers/path.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helpers/path.go b/helpers/path.go index 3c0d530f2..0c18e5397 100644 --- a/helpers/path.go +++ b/helpers/path.go @@ -462,6 +462,8 @@ func FindCWD() (string, error) { return path, nil } +var WalkRootTooShortError = errors.New("Path too short. Stop walking.") + // SymbolicWalk is like filepath.Walk, but it supports the root being a // symbolic link. It will still not follow symbolic links deeper down in // the file structure @@ -469,7 +471,7 @@ func SymbolicWalk(fs afero.Fs, root string, walker filepath.WalkFunc) error { // Sanity check if len(root) < 4 { - return fmt.Errorf("Path to short, cannot walk the root: %s", root) + return WalkRootTooShortError } // Handle the root first