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 β¨
libnbd(3)π¦
β¨ AUTHORS β¨
Richard W.M. Jones π (respect the legend)
β¨ COPYRIGHT β¨
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
- arch rolling: libnbd 1.24.4-1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms