I have a file. Let's call it "x". I'd like to associate "x" with a loopback device in linux. From bash, I'd type:
losetup -f x
That will create something like /dev/loop0 that I can mount wherever I'd like. When it's not mounted, I can destroy the loopback file with something like:
losetup -d /dev/loop0
I'd like to be able to do the same in golang without calling losetup from the go program. Is there a library somewhere to that implements this as I looked through the losetup source, and it looks somewhat tricky, especially the create part.