3 libnbd-golang - how to use libnbd from Go
7 import "libguestfs.org/libnbd"
9 h, err := libnbd.Create()
14 uri := "nbd://localhost"
15 err = h.ConnectUri(uri)
19 size, err := h.GetSize()
23 fmt.Printf("size of %s = %d\n", uri, size)
27 This manual page documents how to use libnbd to access Network Block
28 Device (NBD) servers from the Go programming language. The Go
29 bindings work very similarly to the C bindings so you should start by
34 Create a libnbd handle of type C<Libnbd> by calling C<Create()>.
36 You can either close the handle explicitly by a deferred call to
37 C<h.Close()> or it will be closed automatically when it is garbage
42 Most calls return either a single C<LibnbdError> or a pair
43 C<(ret, LibnbdError)>.
47 This directory contains examples written in Go:
49 L<https://gitlab.com/nbdkit/libnbd/tree/master/golang/examples>