◇ /LANDING/SDK/GO

Context-aware.
Zero deps.

Standard library only. context.Context on every call. Struct-based options. Idiomatic error handling with sentinel errors and wrapped types.

Go 1.21+context.Context0 depsnet/httpgenerics
01 · INSTALL

go get.
That is it.

Zero transitive dependencies. The SDK uses net/http, encoding/json, and crypto/hmac from the standard library. Nothing else.

terminal
02 · CLIENT

Functional options.
Idiomatic Go.

Construct with functional options. Pass context.Context to every call for deadlines, cancellation, and tracing propagation.

main.go
03 · RECORDS

Struct params.
Pointer optionals.

Optional fields use pointer types with helper constructors (relays.String, relays.Int). Required fields are value types. No ambiguity.

records.go
04 · PAGINATION

Auto-paginate.
Or manual.

Use the iterator to auto-paginate through all results, or manage pages manually with Page and PerPage params. Both patterns are first-class.

pagination.go
// Auto-paginate through all records
iter := client.Records.ListAll(ctx, "example.com", nil)

for iter.Next() {
    record := iter.Current()
    fmt.Printf("%s %s -> %s
",
        record.Type, record.Name, record.Content)
}
if err := iter.Err(); err != nil {
    return fmt.Errorf("iterate records: %w", err)
}

// Manual pagination
page1, err := client.Records.List(ctx, "example.com",
    &relays.ListRecordsParams{
        Page:    relays.Int(1),
        PerPage: relays.Int(100),
    },
)
// page1.Meta.Total => 247
// page1.Meta.Page  => 1
05 · ERRORS

errors.Is.
errors.As.

Sentinel errors for common cases. Structured error types for details. All errors implement the standard error interface and support unwrapping.

errors.go
_, err := client.Records.Create(ctx, zone, params)

// Sentinel errors
if errors.Is(err, relays.ErrNotFound) {
    // Zone does not exist
}
if errors.Is(err, relays.ErrRateLimit) {
    // Back off and retry
}

// Structured error details
var validErr *relays.ValidationError
if errors.As(err, &validErr) {
    fmt.Println(validErr.Field)   // "content"
    fmt.Println(validErr.Reason)  // "invalid IPv4"
}

var rateErr *relays.RateLimitError
if errors.As(err, &rateErr) {
    time.Sleep(rateErr.RetryAfter)
}

go get.
Ship DNS.