putnami / go

Go services.
Declared once.

One endpoint declaration gives the HTTP route, typed clients and, with plugins, OpenAPI and gRPC. Data, events, auth and telemetry come with it. Built so a coding agent can write it, test it and run it.

$putnami init --extension go --project api
Read the docs →
// declared once: route, input, output, errors apiPlugin := api.New(httpServer, ClientContract()) apiPlugin.Register(api.Endpoint("GET", "/items/{id}"). Description("Get a single item by id"). Params(api.Type[GetItemParams]()). Returns(api.Type[Item]()). MayThrow(perrors.CodeNotFound). Handle(getItem)) apiPlugin.Register(api.Endpoint("POST", "/items"). Body(api.Type[CreateItemBody]()). ReturnsStatus(201, "Created", api.Type[Item]()). // … the retry policy that its clients read Handle(createItem))
// the composition root: main and its tests share it; … marks a cut func newApp(cfg ServerConfig) (*app.Application, *http.ServerPlugin) { server := http.NewServerPlugin(http.ServerConfig{Port: cfg.Port}) server.Use(http.Recovery()) server.Use(http.RequestID()) server.Use(http.Logging(http.LoggerOptions{ Exclude: []string{"/_/health", "/livez", "/healthz", "/readyz"}, })) … a := app.New("server") a.Use(server) a.Use(platform.NewPlugin(platform.Config{})) // /livez /healthz /readyz /version a.Use(http.NewHealthPlugin()) return a, server }
// another service calls it: generated and typed, // no URL to format, no JSON to decode; … marks a cut func FetchItem(…) (*itemsclient.Item, error) { return items.GetItems(ctx, itemsclient.GetItemsInput{ Path: itemsclient.GetItemsPath{Id: id}, }) } func CreateItem(…) (*itemsclient.Item, error) { return items.CreateItems(ctx, itemsclient.CreateItemsInput{ Body: itemsclient.CreateItemBody{Name: name, Price: &price}, }) } // the binding adds the credential the provider declared
one declaration → route, openapi, proto, clientssamples/service-to-service
one declaration

Write the endpoint once. Every caller follows.

The declaration holds the method, the path, the inputs, the outputs, the errors and the dependencies. Everything on the right comes from it, the OpenAPI and Protobuf rows through their plugins. Change it, and every caller that no longer fits fails its build.

you writeapi.Endpoint(…)plus validate: tags on your Go types
httpRoute and validation400 with the failing fields
openapiThe OpenAPI documentschema/openapi.json
grpcProtobuf service and Connectgrpc, or json over http/1.1
goA typed Go clientgenerated at build
tsA typed TypeScript clientgenerated at build
built for agents

An agent writes it, tests it and runs it.

Each Go module says how to use it. The workspace says what a change touches and what is already decided. A typed contract turns a wrong guess into a build error.

agent session
$ putnami context pack --project items # the project's agent-context document $ putnami test --impacted # Go tests on a real Postgres that putnami test starts $ putnami build # a caller of a changed contract fails here $ putnami serve items # serves items at http://localhost:3000
AI.md

At the root of every Go module: the methods, one example, the limits.

AGENTS.md + skills

How to build, test and add code here. Skills install with the extensions.

decisions/

Settled choices, one file each. An agent reads one before it changes it.

one composition root

Tests build the service with the same function as main, so they cannot drift.

what it saves

Less code to carry.

The table lists what a hand-written service keeps in sync by hand, and what Putnami derives instead.

code · against a hand-written service7 things you stop writing
concernby handwith putnami
openapi documentwritten, kept in syncderived
grpc servicea second definitionsame declaration
typed clientsone per callergenerated, go and ts
input validationan if per fieldvalidate: tags
health probeshandlers per serviceone plugin
service credentialsheaders set by the callerinjected by the binding
test wiringa second graphfork, override one

The first six lines run in go/samples/service-to-service.

secure, operable, tested

Built in, one line each.

Secure

  • An identity resolver, then roles and scopes per route.
  • MayThrow declares each error in the contract and its clients.
  • A rate limit middleware.
  • Signing keys that rotate.
  • A panic answers 500 and the service stays up.

Operable

  • /livez, /readyz, /version from one plugin.
  • Structured logs with a request ID.
  • OpenTelemetry metrics, traces and logs.
  • A clean stop on SIGTERM.
  • Context deadlines on every call.

Tested

  • Fork the container, override one dependency.
  • putnami test gives each run a real Postgres.
  • Tests and main share one composition root.
  • Plain go test underneath.
  • A changed contract fails its callers at build.
polyglot

Talk to any service, in any language.

Your Go service publishes its contract as OpenAPI with the openapi plugin, and as Protobuf with the proto plugin. Go and TypeScript callers get a generated, typed client. Any other language reads the same contract.

Your own .proto services run on grpc-go, next to the declared ones.

Service clients →
your service · go.putnami.devcalled by, and calls
tsA Putnami TypeScript appgenerated client · same contract
goAnother Putnami Go servicegenerated client · json or proto
grpcAny gRPC servicegrpc-go · any .proto
connectBrowsers and REST callersjson over http/1.1
the rest of the service

Explicit wiring, nothing hidden.

Data

A Postgres pool, SQL migrations, a unit of work.

Events

Typed topics, broadcast or one consumer.

Storage and cache

Files and a cache behind one interface each.

Config

Typed structs from the environment, with defaults.

Bounded work

Parallel fan-out with a limit and a deadline.

start

One command, then your loop.

The workspace, a go-server project and its tests. Add a TypeScript app next to it when you need one.

$ putnami init --extension go --project api $ putnami test api $ putnami serve api # every day: only what the change touches $ putnami lint,test,build --impacted