For AI agents: the complete documentation index is available at /hclapi/llms.txt, the full documentation bundle is available at /hclapi/llms-full.txt, and this page is available as Markdown at /hclapi/docs/steps/go.md.

go

Invokes a native Go function registered on the engine. Use this step for logic that cannot be expressed in Starlark or SQL: proprietary business rules, third-party SDKs, outbound HTTP clients, or hardware cryptography.

Declaration

go "<name>" {
  use  = "<registered_function_name>"
  args = {
    city = ctx.request.path.city
  }
}

Attributes

AttributeTypeRequiredDescription
labelstringyesStep identifier; written to steps.<name>
usestringyesFunction name registered on the Engine
argsmapnoEvaluated arguments passed into step.Args

Registration in Go

engine.RegisterStep("services.weather_lookup", func(ctx context.Context, step *hclapi.Step) (any, error) {
    city := step.Args.GetOr("city", "")
    if city == "" {
        return nil, errors.New("missing or empty 'city' argument")
    }

    // Access incoming request headers safely
    authHeader := step.Request.Header("Authorization")

    return map[string]any{
        "city":          strings.ToLower(strings.TrimSpace(city)),
        "temperature_c": 22.5,
        "condition":     "Sunny",
    }, nil
})

The return value is exported under steps.<name>.result.

Panic handling

Panics in a registered function are automatically recovered by the engine, converted to an RFC 9457 500 error response, and don't terminate the server process.