Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Go client

Go Reference

The Go client (go get github.com/aramirez087/Varta/clients/go) is a first-class peer of the Rust varta-client crate. It tracks the same wire-format contract, passes the same tools/vlp-test-vectors.json conformance suite, and interoperates with the same varta-watch observer binary.

Install

go get github.com/aramirez087/Varta/clients/go

Requires Go 1.21+. The base module (UDS + plaintext UDP) has no registry dependencies. ConnectSecureUDP adds golang.org/x/crypto.

20-line example

package main

import (
    "log"
    "time"

    varta "github.com/aramirez087/Varta/clients/go"
)

func main() {
    // Connect once. path must match --socket on your observer.
    agent, err := varta.Connect("/run/varta/varta.sock")
    if err != nil {
        log.Fatal(err)
    }
    defer agent.Close()

    for {
        if outcome := agent.Beat(varta.StatusOK, 0); outcome.IsDropped() {
            // Four-way taxonomy mirrors the Rust client:
            log.Printf("varta: dropped (%s)", outcome.DropReason())
        }
        time.Sleep(500 * time.Millisecond)
    }
}

For payload encoding, fork-safety, the panic-handler subpackage, the full transport comparison, and the complete API parity matrix see the package README: clients/go/README.md.

Transports

TransportStatusNotes
Unix Domain SocketsSupportedvarta.Connect(path). Stdlib-only. Classified BeatOrigin::KernelAttested only on observer platforms with pathname-UDS peer credentials; macOS observers treat pathname UDS as socket-mode-only, so recovery is refused.
Plaintext UDPSupportedvarta.ConnectUDP(host, port). Connected-mode socket. Beats classified NetworkUnverified; recovery refused.
Secure UDP (ChaCha20-Poly1305)Supportedvarta.ConnectSecureUDP(host, port, key). Adds golang.org/x/crypto.
Master-key secure UDPSupportedvarta.ConnectSecureUDPWithMaster(host, port, masterKey)

Stability

Source