libnbd-golang3
How to use libnbd from go
Usage
import "libguestfs.org/libnbd"h, err := libnbd.Create()if err != nil {panic(err)}defer h.Close()uri := "nbd://localhost"err = h.ConnectUri(uri)if err != nil {panic(err)}size, err := h.GetSize()if err != nil {panic(err)}fmt.Printf("size of %s = %d\n", uri, size)
Overview
This manual page documents how to use libnbd to access Network Block Device (NBD) servers from the Go programming language. The Go bindings work very similarly to the C bindings so you should start by reading libnbd(3).
Handles
Create a libnbd handle of type "Libnbd" by calling Create().
You can either close the handle explicitly by a deferred call to "h.Close()" or it will be closed automatically when it is garbage collected.
Errors
Most calls return either a single "LibnbdError" or a pair "(ret, LibnbdError)".
Examples
This directory contains examples written in Go:
https://gitlab.com/nbdkit/libnbd/tree/master/golang/examples
Releases
4 releases since Debian 11 (Bullseye); the text changed 3 times.