Instantiate the backend manually for later use in diskfs.OpenBackend
()
| 174 | |
| 175 | // Instantiate the backend manually for later use in diskfs.OpenBackend |
| 176 | func ExampleOpenBackend_backend() { |
| 177 | // some exemplary fs.FS |
| 178 | dirfs := os.DirFS("/tmp/images") |
| 179 | // the fs.File we'll use |
| 180 | f, err := dirfs.Open("theImage.raw") |
| 181 | check(err) |
| 182 | |
| 183 | theBackend := file.New(f, false) |
| 184 | |
| 185 | // As opposed to File example, theBackend will be used as is (i.e. not wrapped). |
| 186 | // This usage scenario is for upcoming support for other backends (qcow2 and such). |
| 187 | theDisk, err := diskfs.OpenBackend(theBackend) |
| 188 | check(err) |
| 189 | unused(theDisk) |
| 190 | } |