A losetup implementation for go-lang.
go get github.com/freddierice/go-losetup/v2
// attach a raw file to a loop device
dev, err := losetup.Attach("rawfile.img", 0, false)
if err != nil {
// error checking
}
fmt.Printf("attached rawfile.img to %v\n", dev.Path())
err := dev.Detach()
if err != nil {
// error checking
}