libnbd-golang(3)

πŸ’… libnbd-golang πŸ’…

okay so this is the libnbd-golang(3) page, part of the LIBNBD manual set β€” it's literally your whole guide to using libnbd from Go, and bestie, it's shorter than you'd think πŸŽ€


✨ NAME ✨

libnbd-golang β€” how to use libnbd from Go πŸ¦‹


✨ SYNOPSIS ✨

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)

like… that's it. that's the whole vibe. connect, get size, print, slay πŸ’…


✨ DESCRIPTION ✨

this manual page documents how to use libnbd to access Network Block Device (NBD) servers from the Go programming language 🫢

and here's the good news: the Go bindings work very similarly to the C bindings, so you should start by reading libnbd(3) first β€” no cap, it's the main character here and this page is its hype squad πŸ“šβœ¨


✨ HANDLES ✨

create a libnbd handle of type Libnbd by calling Create(). iconic, effortless, done πŸ’–

then you've got two whole options for closing it:

  • close the handle explicitly with a deferred call to h.Close() β€” very responsible of you, we love a type-A queen πŸ‘‘
  • or just… don't, because it'll be closed automatically when it's garbage collected 🌈 (the Go runtime is your bestie, it's got you)

✨ ERRORS ✨

most calls return either:

  • a single LibnbdError, or
  • a pair (ret, LibnbdError)

that's the whole system, bestie. nothing cursed, nothing mysterious 😭


✨ EXAMPLES ✨

this directory contains examples written in Go β€” go browse, go copy, go thrive 🧚

https://gitlab.com/nbdkit/libnbd/tree/master/golang/examples

✨ SEE ALSO ✨


✨ AUTHORS ✨

Richard W.M. Jones 🌟 (respect the legend)


Copyright Red Hat 🎩


✨ LICENSE ✨

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. πŸ“œ

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. ⚠️ (yes, the all-caps screaming is legally required, it's giving contract energy πŸ’€)

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA πŸ’πŸ’Œ


fr fr read the license, it's not just decoration πŸ’œ

and that's a wrap, bestie πŸŽ€ this was libnbd-1.24.4, dated 2026-10-13 β€” libnbd-golang(3), out πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from