cubbitnet is a Go library providing node-to-node communication primitives, allowing you to create nodes that send and receive messages.
pkg/- Exportable packagesinternal/- Internal packagesexamples/- Example programs demonstrating usagetest/- End-to-end testsflake.nix- Nix flake for development environment and CI
Make sure you have Go 1.24 installed, or use the provided Nix environment:
nix develop
go mod tidyYou can run the example without changing directory into the example folder. From the root of the project, simply execute:
go run ./examples/simple
go run ./examples/dbMake sure you run the command from the project root (where go.mod is located) to preserve the module context.
Run all tests with:
go test ./...Use the provided Nix flake environment and run:
golangci-lint runYou can generate or view documentation locally using the built-in go doc tool.
To display documentation for a package, run:
go doc ./pkg/nodeAlternatively, you can install (it is already provided by the Nix shell) and run godoc to start a local web server with browsable docs:
godoc -http=:6060Then open your browser at http://localhost:6060/pkg/ to explore the documentation.
The project uses GitHub Actions with Nix to run build, test, and lint steps separately. See .github/workflows/ci.yml for details.
This library requires Nix to be installed.
To add it to your Bazel project, include the following in your WORKSPACE file:
# rules_nixpkgs
http_archive(
name = "io_tweag_rules_nixpkgs",
strip_prefix = "rules_nixpkgs-a0548813a1d3d3d08e2f1952ea0a9b1777ed160b",
urls = ["https://github.com/carlo-aromando/rules_nixpkgs/archive/a0548813a1d3d3d08e2f1952ea0a9b1777ed160b.tar.gz"],
)
load("@io_tweag_rules_nixpkgs//nixpkgs:repositories.bzl", "rules_nixpkgs_dependencies")
rules_nixpkgs_dependencies()
# cubbitnet dependencies
http_archive(
name = "com_github_carlo_aromando_cubbitnet",
strip_prefix = "cubbitnet-0.1.8",
url = "https://github.com/carlo-aromando/cubbitnet/archive/refs/tags/v0.1.8.tar.gz",
)
load("@com_github_carlo_aromando_cubbitnet//bazel:deps.bzl", "cubbitnet_dependencies")
cubbitnet_dependencies()After adding the required dependencies to your WORKSPACE file (as shown above), you can use the library in your Bazel Go targets.
Here's a minimal example using go_binary:
BUILD.bazel
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
go_binary(
name = "app",
embed = [":lib"],
)
go_library(
name = "lib",
srcs = ["main.go"],
importpath = "example.com/app",
deps = [
"@com_github_carlo_aromando_cubbitnet//pkg/db",
],
)main.go
package main
import (
"github.com/carlo-aromando/cubbitnet/pkg/db"
)
func main() {
db.Test()
}Build the binary with:
bazel build //:app