From 1ddc17bc506f36611059c43734ec0ac746a82ab2 Mon Sep 17 00:00:00 2001 From: Niklas Halonen Date: Wed, 16 Aug 2023 22:27:34 +0300 Subject: [PATCH] Fix symlink builder to recursively walk the vendor directory Fixes https://github.com/nix-community/gomod2nix/issues/20 --- builder/symlink/symlink.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/builder/symlink/symlink.go b/builder/symlink/symlink.go index e5ee0cd..c3fc4ac 100644 --- a/builder/symlink/symlink.go +++ b/builder/symlink/symlink.go @@ -91,19 +91,8 @@ func populateVendorPath(vendorPath string, src string) { innerSrc := filepath.Join(src, f.Name()) dst := filepath.Join(vendorPath, f.Name()) if err := os.Symlink(innerSrc, dst); err != nil { - // assume it's an existing directory, try to link the directory content instead. - // TODO should we do this recursively? - files, err := os.ReadDir(innerSrc) - if err != nil { - panic(err) - } - for _, f := range files { - srcFile := filepath.Join(innerSrc, f.Name()) - dstFile := filepath.Join(dst, f.Name()) - if err := os.Symlink(srcFile, dstFile); err != nil { - fmt.Println("ignoring symlink error", srcFile, dstFile) - } - } + fmt.Println("symlink error, trying", innerSrc, err) + populateVendorPath(dst, innerSrc); } } }