I noticed that I have 22,896 duplicate files in my GOMODCACHE looking only at candidates that are at the same relative path within in the same module name, but just at different versions.
In other words, many files in a module don't change between versions, say, 1.0.0 and 1.0.1.
Maybe go mod download could do clonefile (macOS, APFS, cp -c) or FICLONE (Linux, XFS/btfs/etc, cp --reflink) to save disk space when possible?
The search doesn't cost much: you don't need to sha256 all files in GOMODCACHE looking for dups. Just looking at same relative path in other versions of the same module gets almost all of the win.
And then you can detect files already sharing backing storage with F_CTNL F_LOG2PHYS_EXT on macOS or fiemap on Linux.
I noticed that I have 22,896 duplicate files in my GOMODCACHE looking only at candidates that are at the same relative path within in the same module name, but just at different versions.
In other words, many files in a module don't change between versions, say, 1.0.0 and 1.0.1.
Maybe
go mod downloadcould doclonefile(macOS, APFS,cp -c) orFICLONE(Linux, XFS/btfs/etc,cp --reflink) to save disk space when possible?The search doesn't cost much: you don't need to sha256 all files in GOMODCACHE looking for dups. Just looking at same relative path in other versions of the same module gets almost all of the win.
And then you can detect files already sharing backing storage with F_CTNL
F_LOG2PHYS_EXTon macOS or fiemap on Linux.