go-diskimages

Pure-Go disk-image tooling — create, convert, inspect and patch VM disk images (raw, qcow2, Apple dmg, OCI-Tart) with no cgo and no qemu-img or hdiutil on the path.

CGO_ENABLED=0 no qemu-img / hdiutil unified diskimage toolkit per-format packages over a shared interface BSD-3-Clause
Documentation GitHub

One concern lives here — VM disk images. A unified diskimage toolkit sits on top of small, focused per-format packages (raw, qcow2, dmg, tart-oci, and a shared interface), so each format is independently usable yet they compose into one create / convert / resize / inspect surface. Everything is plain go build with CGO_ENABLED=0 — no qemu-img, no hdiutil, no C toolchain.

Honest about coverage and platforms. The format packages parse the on-disk structures directly — QCOW2 v2 headers and L1/L2 tables, Apple UDIF koly trailers and blkx run tables. Some paths are deliberately bounded: QCOW2 grows but never shrinks; UDIF write support is limited to the formats listed below (ADC and bzip2 are read-only). GRUB-config patching lives in the sibling go-bootloaders/grub package, not in this org.

Repositories

diskimage libcore

Unified disk-image toolkit (create / convert / resize / inspect)

module github.com/go-diskimages/diskimage · ships cmd/diskimage CLI

Creates, converts, and resizes VM disk images (raw / DMG, plus QCOW2 via the CLI), opens them as a uniform BlockDevice, detects the inner filesystem (ext4, APFS, FAT32, NTFS, exFAT, btrfs, XFS, ZFS), reads/writes ext4 volume labels, and layers LUKS or APFS FileVault decryption. Used to prepare images for Apple Virtualization.framework VMs. Pure Go, cross-platform. GRUB patching and OCI/Tart extraction live in the sibling go-bootloaders/grub and tart-oci packages.

interface libcore

Shared format interfaces (Creator / Detector / RawConverter / Resizer)

module github.com/go-diskimages/interface · zero-dependency

Defines the common interfaces every format package satisfies. Thanks to Go's structural typing, format packages need not import it — only callers that use formats polymorphically do. No dependencies beyond the standard library.

qcow2 libformat

QCOW2 v2 codec (Create / Detect / ToRaw / Resize)

module github.com/go-diskimages/qcow2 · pure Go

Pure-Go QCOW2 v2 reader/writer: create sparse images, detect by magic bytes, convert to raw, and grow the virtual size in place by extending the L1 table. Shrinking is rejected (it could silently discard data). Satisfies the interface module's Format without importing it.

dmg libformat

Apple UDIF disk-image helpers (detect / pack / unpack)

module github.com/go-diskimages/dmg · no hdiutil / plutil

Pure-Go Apple UDIF (.dmg) helpers — no external macOS tools, works on every platform. Parses the koly trailer and blkx tables (RAW / NOCOPY / FREE / LZFSE / ZLIB runs). Reads UDRW/UDRO/UDZO/UDSP; writes UDRW/UDRO/UDZO/UDSP. ADC (UDCO) and bzip2 (UDBZ) are read-only — write is not supported.

raw libformat

Unstructured (identity) disk-image codec

module github.com/go-diskimages/raw · pure Go

The trivial identity format: byte-for-byte disk contents, no header or metadata. Create writes a sparse zero-filled file, ToRaw is a straight copy, Detect is the negative/fallback case, and Resize both grows and shrinks. Satisfies the interface module's Format without importing it.

tart-oci libformat

Tart/OCI VM-image puller (registry v2, digest-verified)

module github.com/go-diskimages/tart-oci · pure Go

Pulls Tart VM images stored as OCI artifacts (e.g. ghcr.io/cirruslabs/*), speaking the OCI distribution v2 API. Verifies every blob against its digest, decompresses Apple-LZ4-framed disk layers, and materializes a byte-exact raw disk. No tart, no hdiutil, no darwin-only code.

Every module is pure Go with CGO_ENABLED=0 and no external command-line tools. Format packages parse the on-disk structures themselves and satisfy the shared interface module by structural typing, without importing it. Capabilities and their limits are stated plainly on each card rather than implied. BSD-3-Clause throughout.