From 9a2efe5a6f5c98b16302d09dc964d23846debf3d Mon Sep 17 00:00:00 2001 From: Michael Eisendle Date: Sat, 8 Mar 2014 14:31:06 +0100 Subject: [PATCH] Make mustCopyDir follow symlinks. Applications symlinked into the GOPATH fail to build properly under linux, this fixes it. --- revel/util.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/revel/util.go b/revel/util.go index f49221d..248eadf 100644 --- a/revel/util.go +++ b/revel/util.go @@ -66,10 +66,19 @@ func mustChmod(filename string, mode os.FileMode) { // Additionally, the trailing ".template" is stripped from the file name. // Also, dot files and dot directories are skipped. func mustCopyDir(destDir, srcDir string, data map[string]interface{}) error { - return filepath.Walk(srcDir, func(srcPath string, info os.FileInfo, err error) error { + var realSrcDir string + // handle symlinked source-direcories + f, err := os.Lstat(srcDir) + if err == nil && f.Mode()&os.ModeSymlink == os.ModeSymlink { + realSrcDir, _ = os.Readlink(srcDir) + } else { + realSrcDir = srcDir + } + + return filepath.Walk(realSrcDir, func(srcPath string, info os.FileInfo, err error) error { // Get the relative path from the source base, and the corresponding path in // the dest directory. - relSrcPath := strings.TrimLeft(srcPath[len(srcDir):], string(os.PathSeparator)) + relSrcPath := strings.TrimLeft(srcPath[len(realSrcDir):], string(os.PathSeparator)) destPath := path.Join(destDir, relSrcPath) // Skip dot files and dot directories.