go-dimail

A pure-Go client for the Dimail API — generated from the API's OpenAPI document, no cgo.

pure Go · zero cgo generated from OpenAPI 96 typed models 91 methods Basic → bearer auth typed APIError 100% coverage 6 arches go generate
Documentation GitHub
Documentation (MkDocs Material + mike) License: BSD-3-Clause Go 1.26.4+ Go Reference

go-dimail is a pure-Go (no cgo) client for the Dimail API, the mail-hosting management API of the French government's La Suite numérique platform. The typed models and request methods are generated from the API's own OpenAPI document (committed in the repo) by an in-tree generator, so the whole surface — 96 models and 91 methods across users, domains, mailboxes, aliases, forwards, identities and the admin endpoints — stays faithful to the spec and regenerates with go generate ./.... The hand-written runtime adds Basic→bearer authentication, an HTTP transport, and a typed APIError. 100% test coverage, race-clean, CI green across 6 architectures.

Generated from OpenAPI ready

Typed models and request methods are generated from the API’s own committed openapi.json by an in-tree generator. Refresh with go generate ./...; CI fails if the checked-in code drifts from the spec.

Full API surface ready

96 typed models and 91 methods — one per operation: users, domains, mailboxes (v1 + v2), aliases, forwards, allows, identities, app-passwords, the /my views, and the /system and /logs admin surface.

Authentication ready

HTTP Basic → bearer token. Login(ctx) mints and stores a token; the client sends the bearer when set and falls back to Basic otherwise. Functional options for base URL, HTTP client, token and User-Agent.

Typed errors ready

Every non-2xx response is an *APIError carrying the status, the request, the raw body and the FastAPI detail, with NotFound() / Unauthorized() / Forbidden() / Conflict() predicates.

CGO-free, 6 arches ready

Pure Go, no cgo: the same test binary builds and runs identically on amd64, arm64, riscv64, loong64, ppc64le and s390x. 100% test coverage, race-clean, enforced in CI.

Ruby face ready

The Ruby-idiomatic adapter lives in the sibling org go-ruby-dimail — a Session that returns Ruby Hashes/Arrays, bound by rbgo as require "dimail".

Generated from source for reproducibility: the OpenAPI document and the generator both live in the tree, and CI fails if the checked-in generated code drifts from the spec. The client is CGO-free, so it cross-compiles and embeds anywhere. Its Ruby-idiomatic face — a Hash-returning Session bound by rbgo as require "dimail" — lives in the sibling org go-ruby-dimail.