Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 768 Bytes

README.md

File metadata and controls

40 lines (30 loc) · 768 Bytes

udisks

udisks gives you high level access to Linux system drives and block devices wrapping the udisk2 interfaces.

An example command line udisks client to list drives and block device properties can be installed with:

go install github.com/rubiojr/go-udisks/cmd/udisks@latest
package main

import (
	"encoding/json"
	"fmt"

	"os"

	"github.com/rubiojr/go-udisks"
)

func main() {
	client, err := udisks.NewClient()
	if err != nil {
		panic(err)
	}

	// List all block devices available to UDisks2
	devs, err := client.BlockDevices()
	if err != nil {
		panic(err)
	}
	pretty(devs)
}

func pretty(dev interface{}) {
	prettyString, _ := json.MarshalIndent(dev, "", "  ")
	fmt.Println(string(prettyString))
}