Go bindings for libnvme - NVMe management library for Linux.
libnvme-go provides Go language bindings to the libnvme C library, enabling Go applications to manage NVMe and NVMe-oF (NVMe over Fabrics) devices.
- Connect to NVMe-oF controllers
- Disconnect from NVMe-oF controllers
- Support for multiple transport types (TCP, RDMA)
- Comprehensive error handling
- Type-safe Go API wrapping libnvme C functions
- Go 1.25 or later
- libnvme library and development headers
- GCC (for CGO compilation)
Fedora/RHEL:
sudo dnf install libnvme-devel gcc golangDebian/Ubuntu:
sudo apt install libnvme-dev gcc golanggo get github.com/nixpanic/libnvme-gopackage main
import (
"fmt"
"log"
"github.com/nixpanic/libnvme-go"
)
func main() {
args := &libnvme.ConnectArgs{
Traddr: "192.168.1.100", // Target IP address
Trsvcid: "4420", // Port number
Subsysnqn: "nqn.2014-08.org.nvmexpress:uuid:my-subsystem",
Transport: "tcp", // or "rdma"
}
err := libnvme.ConnectCtrl(args)
if err != nil {
log.Fatalf("Failed to connect: %v", err)
}
fmt.Println("Successfully connected to NVMe-oF controller")
}err := libnvme.DisconnectCtrl(args)
if err != nil {
log.Fatalf("Failed to disconnect: %v", err)
}
fmt.Println("Successfully disconnected from NVMe-oF controller")Run the unit tests:
go test -vRun tests in short mode (skips integration tests):
go test -v -shortBuild and test in a containerized environment:
# Build the container
podman build -t libnvme-go -f tests/Containerfile .
# Run tests in the container
podman run --rm libnvme-go go test -vgo buildgo fmt ./...This project uses GitHub Actions for continuous integration. On every pull request and push to main:
- Container is built with all dependencies
- Unit tests are executed
- Code is compiled to verify build success
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit issues or pull requests.
- This library wraps the libnvme C library
- Code generated with AI assistance from Claude Code (Anthropic)