Fix symlink builder to recursively walk the vendor directory

Fixes https://github.com/nix-community/gomod2nix/issues/20
This commit is contained in:
Niklas Halonen 2023-08-16 22:27:34 +03:00
parent 3cbf3a51fe
commit 1ddc17bc50
No known key found for this signature in database
GPG key ID: 7912D083CF630FD3

View file

@ -91,19 +91,8 @@ func populateVendorPath(vendorPath string, src string) {
innerSrc := filepath.Join(src, f.Name()) innerSrc := filepath.Join(src, f.Name())
dst := filepath.Join(vendorPath, f.Name()) dst := filepath.Join(vendorPath, f.Name())
if err := os.Symlink(innerSrc, dst); err != nil { if err := os.Symlink(innerSrc, dst); err != nil {
// assume it's an existing directory, try to link the directory content instead. fmt.Println("symlink error, trying", innerSrc, err)
// TODO should we do this recursively? populateVendorPath(dst, innerSrc);
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)
}
}
} }
} }
} }