Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"languages/swift",
"languages/kotlin",
"languages/javascript",
"languages/go",
"languages/wasm-browser"
]
},
Expand Down
78 changes: 78 additions & 0 deletions languages/go.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: "Go"
description: "Use iroh from Go via the [iroh-ffi](https://github.com/n0-computer/iroh-ffi) bindings."
---

[`iroh-go`](https://git.coopcloud.tech/decentral1se/iroh-go) is still
considered experimental but ready for testing and open for contribution to
improve the quality and reliability of the bindings. There is a specific focus
on making the installation and cross platform support [as simple as
possible](https://git.coopcloud.tech/decentral1se/iroh-go#motivation).

| Platform | Architectures |
| --- | --- |
| Linux | x86_64, aarch64 (musl) |

- **API reference:** [Go API docs](https://godocs.io/git.coopcloud.tech/decentral1se/iroh-go)
- **Examples:** [iroh-go/examples](https://git.coopcloud.tech/decentral1se/iroh-go/src/branch/main/examples)
- **All languages:** [platform support matrix](/languages#platform-support)

## Install

We're aiming to publish a stable tag once we see more usage and adoption of the
Go bindings.

```bash
go get git.coopcloud.tech/decentral1se/iroh-go
```

## Hello, iroh

```go
package main

import (
"fmt"

iroh "git.coopcloud.tech/decentral1se/iroh-go"
)

var (
alpn = []byte("iroh-go-hello/0")
)

func main() {
preset := iroh.PresetN0()
opts := iroh.EndpointOptions{
Preset: &preset,
Alpns: &[][]byte{alpn},
}

endpoint, err := iroh.EndpointBind(opts)
if err != nil {
panic(err)
}

endpoint.Online()

fmt.Println("endpoint id:", endpoint.Id())
}
```

This binds an endpoint using the N0 preset (public discovery + default relays),
waits until it has a home relay, and prints its 64-character endpoint id. Run
it with `go run`.

## Next steps

<Card title="Bidirectional chat" icon="rocket" href="https://git.coopcloud.tech/decentral1se/iroh-go/src/branch/main/examples/pairchat" horizontal>
Connect two endpoints and stream messages between them.
</Card>

<Card title="Multiple live connections" icon="sun" href="https://git.coopcloud.tech/decentral1se/iroh-go/src/branch/main/examples/timeserve" horizontal>
Connect multiple endpoints and broadcast messages.
</Card>

<Card title="iroh-go repository" icon="git" href="https://git.coopcloud.tech/decentral1se/iroh-go" horizontal>
Source, examples, and issue tracker for the iroh Go FFI bindings. Contributions are welcome!
</Card>
29 changes: 15 additions & 14 deletions languages/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Overview"
description: "Use iroh from Rust, Python, Swift, Kotlin, or JavaScript."
description: "Use iroh from Rust, Python, Swift, Kotlin, JavaScript or Go."
---

iroh is available in Rust, Python, Swift, Kotlin, and JavaScript. Pick the language that fits your app and follow its guide to get a working endpoint in minutes.
Expand All @@ -12,6 +12,7 @@ iroh is available in Rust, Python, Swift, Kotlin, and JavaScript. Pick the langu
| [Swift](/languages/swift) | Official | iOS + macOS |
| [Kotlin](/languages/kotlin) | Official | JVM + Android |
| [JavaScript](/languages/javascript) | Official | Node.js via N-API |
| [Go](/languages/go) | Community | FFI bindings via [iroh-ffi](https://github.com/n0-computer/iroh-ffi) |

All five official bindings share the same basic API surface for sending streams
or datagrams over QUIC. The Rust language bindings are the most complete and
Expand All @@ -25,19 +26,19 @@ up-to-date, and contain custom configuration and protocol features.

The [n0.computer](https://n0.computer) team offers official support for the following platforms.

| Platform | Rust | Python | Swift | Kotlin | JavaScript |
| --- | --- | --- | --- | --- | --- |
| iOS (device + sim) | ✓ | — | ✓ | — | — |
| Android (aarch64, armv7) | ✓ | — | — | ✓ | ✓ |
| macOS arm64 | ✓ | ✓ | ✓ | ✓ | ✓ |
| macOS x86_64 | ✓ | ✓ | ✗ | ✓ | ✗ |
| Linux x86_64 (glibc) | ✓ | ✓ | — | ✓ | ✓ |
| Linux x86_64 (musl) | ✓ | ✗ | — | ✗ | ✓ |
| Linux aarch64 (glibc) | ✓ | ✓ | — | ✓ | ✓ |
| Linux aarch64 (musl) | ✓ | ✗ | — | ✗ | ✓ |
| Linux armv7 | ✓ | ✗ | — | ✗ | ✓ |
| Windows x86_64 | ✓ | ✓ | — | ✓ | ✓ |
| Windows aarch64 | ✓ | ✗ | — | ✗ | ✓ |
| Platform | Rust | Python | Swift | Kotlin | JavaScript | Go |
| --- | --- | --- | --- | --- | --- | -- |
| iOS (device + sim) | ✓ | — | ✓ | — | — | - |
| Android (aarch64, armv7) | ✓ | — | — | ✓ | ✓ | - |
| macOS arm64 | ✓ | ✓ | ✓ | ✓ | ✓ | - |
| macOS x86_64 | ✓ | ✓ | ✗ | ✓ | ✗ | - |
| Linux x86_64 (glibc) | ✓ | ✓ | — | ✓ | ✓ | - |
| Linux x86_64 (musl) | ✓ | ✗ | — | ✗ | ✓ | ✓ |
| Linux aarch64 (glibc) | ✓ | ✓ | — | ✓ | ✓ | - |
| Linux aarch64 (musl) | ✓ | ✗ | — | ✗ | ✓ | ✓ |
| Linux armv7 | ✓ | ✗ | — | ✗ | ✓ | - |
| Windows x86_64 | ✓ | ✓ | — | ✓ | ✓ | - |
| Windows aarch64 | ✓ | ✗ | — | ✗ | ✓ | - |

<Card title="Need a language we don't support?" icon="envelope" href="https://cal.com/team/number-0/iroh-services" horizontal>
Get in touch and tell us what you're building. We can prioritize new bindings or help you maintain your own.
Expand Down