From d906a5994a3e847c8482e458ad6bc3e36f571f36 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 12 Jul 2016 09:40:45 -0400 Subject: [PATCH] Not all files will have a symlink The linkname field in the header might not always have a value. Need to check empty linkname. Signed-off-by: Stephen Chung --- keywords.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/keywords.go b/keywords.go index f629519..dc008ae 100644 --- a/keywords.go +++ b/keywords.go @@ -206,7 +206,10 @@ var ( } linkKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) { if sys, ok := info.Sys().(*tar.Header); ok { - return fmt.Sprintf("link=%s", sys.Linkname), nil + if sys.Linkname != "" { + return fmt.Sprintf("link=%s", sys.Linkname), nil + } + return "", nil } if info.Mode()&os.ModeSymlink != 0 {