Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rubiojr/go-udisks

Linux UDisks2 (dbus) easy access from Go
https://github.com/rubiojr/go-udisks

dbus udisks2

Last synced: about 1 month ago
JSON representation

Linux UDisks2 (dbus) easy access from Go

Awesome Lists containing this project

README

        

# udisks

udisks gives you high level access to Linux system drives and block devices wrapping the [udisk2](http://storaged.org/doc/udisks2-api/) 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
```

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