Go FFI bindings for iroh https://iroh.computer
  • Go 72.3%
  • C 27.3%
  • Shell 0.4%
Find a file
2026-07-31 21:59:09 +02:00
examples test: first run at testing 2026-07-31 21:39:27 +02:00
iroh-go feat: v1.1.0 bindings 2026-07-17 13:08:20 +02:00
libs feat: v1.1.0 bindings 2026-07-17 13:08:20 +02:00
licenses feat: apache2 & mit licenses 2026-06-28 00:11:53 +02:00
scripts feat: add aarch64-unknown-linux-musl 2026-06-26 06:40:52 +02:00
.drone.yml test: first run at testing 2026-07-31 21:39:27 +02:00
.gitignore feat: better error handling 2026-07-23 17:57:42 +02:00
errors.go refactor: rework examples, wording and fmt.Errorf 2026-07-31 21:17:40 +02:00
go.mod feat: init 2026-06-23 14:41:39 +02:00
iroh_ffi.go feat: v1.1.0 bindings 2026-07-17 13:08:20 +02:00
iroh_ffi.h feat: v1.1.0 bindings 2026-07-17 13:08:20 +02:00
libs.go feat: add aarch64-unknown-linux-musl 2026-06-26 06:40:52 +02:00
README.md docs: version support [ci skip] 2026-07-31 21:59:09 +02:00

iroh-go

Build Status

WARNING Highly Experimental ™️

Go FFI bindings for iroh via iroh-ffi.

Motivation

The goal is to provide, as far as possible, seamless "just go build it" support for Go iroh hackers without requiring them to deal with shared libraries, the Rust toolchain or a deepdive in how FFI works. The current approach is to embed libiroh as a staticlib built with Rust for each platform. We use musl to avoid glibc incompatibilities on different linux systems. It's then possible to build a static binary with go build or with Zig. iroh-go does require CGO_ENABLED=1.

Version support

Platform support

NOTE More platform can be provided on request and pending some support to build binaries for specific architectures. If you would like to help out, please let us know! See #8 and #9 for more.

  • x86_64-unknown-linux-musl
  • aarch64-unknown-linux-musl

Documentation

Examples

See examples.

Run your own iroh-relay

See iroh-relay if you want more small footprint static binary goodness. You can also make use of the upstream provided docker image: n0computer/iroh-relay.

Local hacking

First, run iroh-relay in development mode with noisy logging.

RUST_LOG=info,iroh_relay=debug ./iroh-relay --dev

You can then use http://localhost:3340 as the default location of your own relay in the construction of your endpoint as follows. Once you create an endpoint, you should see your relay respond locally with corresponding logs.

preset := iroh.PresetN0DisableRelay()
relay, _ := iroh.RelayModeCustomFromUrls([]string{"http://localhost:3340"})
opts := iroh.EndpointOptions{
    Preset:    &preset,
    RelayMode: &relay,
    // ...moar config...
}

Generate bindings

See iroh-go for the Rust toolchain configuration. Run ./scripts/generate.sh to build a new set of libraries which end up vendored in libs.

Who is using it?

NOTE Please add your own if you're using iroh-go 🙏

Known issues

  • We patched the upstream iroh-ffi endpoint.rs to fix an incompatibility with uniffi-bindgen-go. See this commit for more.
  • We patched the upstream iroh-ffi Cargo.toml to remove the crate-type configuration when runnings builds here. See this commit for more.
  • Error handling is not super ergonomic due to iroh-ffi#263. We have created an error handling wrapper API which is documented in ./examples/errors to improve on the situation.

Licenses

Apache 2.0 & MIT, following the upstream licensing choices in iroh-ffi.