Skip to content

rubiojr/go-udisks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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))
}

About

Linux UDisks2 (dbus) easy access from Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages