Is there a package that takes care of the entire process for moving files/directories?
For example, if the source and destination are on the same partition use os.Rename, if they are on different partitions copy the source to the destination and if there were no errors delete the source.
Is there a package that does all that for me? Ideally, it should support Linux and Windows.
Hello there, I had some code which I use in my project as external module. You can check it here. Dunno if it’s exactly what you are looking for, and sometimes it’s still work in progress.
You got pretty close, it is very useful to move between different partitions (from disk C to D for example), when I want to move in the same partition (D:\someFolder to D:\anotherFolder for example) your package still makes a complete copy when you should just use an os.Rename().
Knowing if the source and destination are in the same partition seems not as simple as it seems.
As a review I would say that all that remains is to create any dst directory for each file(s) to be moved to avoid the error that os.Rename returns when the destination directory does not exist.
I’ve added some updates and marked them as v1.2.0-a4898caa. I tested move operations and it uses os.Rename where possible and creates dest subfolders if required.