generator icon indicating copy to clipboard operation
generator copied to clipboard

[FEATURE] Add Go support for baked-in client templates

Open devxdh opened this issue 3 weeks ago • 1 comments

Why do we need this improvement?

When the older standalone generator templates were retired to the archive organization, the Go template (go-watermill-template) was archived along with them. As noted in earlier monorepo discussions, the primary reason Go was not rebuilt as a modern baked-in template was the lack of an active Go contributor to write and support it (asyncapi/community#3495).

Go is one of the most widely used languages for networking APIs and real-time backend services. Having an official, tested Go client generator would be a significant addition for the AsyncAPI community.

How will this change help?

Developers can automatically generate clean Go code to connect, send, and receive WebSocket messages directly from their AsyncAPI config, giving the community an official, maintained Go client generator that stays up to date with the latest spec.

Screenshots

No response

How could it be implemented/designed?

Phased Protocol Rollout

Just as the monorepo onboarded WebSocket first for JavaScript, Python, Dart, and Java before expanding into other protocols like Kafka, the plan for Go is to follow the same phased roadmap:

  • Phase 1 (Initial Target): Go WebSocket client template (packages/templates/clients/websocket/go)
  • Phase 2 (Subsequent Target): Go Kafka client template (packages/templates/clients/kafka/go)

Starting with WebSocket allows us to establish the Go component branches in packages/components, establish the idiomatic Go project scaffolding (go.mod, dependency management, client struct patterns), and validate the it against the existing test suites.

What the Generated Code Looks Like

The generated code can use an already established library like gorilla/websocket for connection handling and look something like this:

package client

import (
    "github.com/gorilla/websocket"
)

type HoppscotchClient struct {
    url  string
    conn *websocket.Conn
}

func NewHoppscotchClient(url string) *HoppscotchClient {
    return &HoppscotchClient{url: url}
}

func (c *HoppscotchClient) Connect() error {
    conn, _, err := websocket.DefaultDialer.Dial(c.url, nil)
    if err != nil {
        return err
    }
    c.conn = conn
    return nil
}

func (c *HoppscotchClient) Close() error {
    if c.conn != nil {
        return c.conn.Close()
    }
    return nil
}

High-Level Implementation Plan

  1. Shared Components: Extend the existing components in packages/components (DependencyProvider, Connect, CloseConnection, RegisterMessageHandler, SendOperations) with Go branches to emit the client methods and structs.
  2. Template Package: Scaffold packages/templates/clients/websocket/go with the standard .ageneratorrc and entrypoint files following the baked-in templates guide.
  3. Tests & Verification:
    • Add tests for the Go branches in packages/components/test/.
    • Add integration tests in packages/templates/clients/websocket/test/integration-test/.
    • Add a tester-go container in microcks-podman.yml to run automated acceptance tests (go test) against the live Microcks mock server in CI.

🚧 Breaking changes

No

👀 Have you checked for similar open issues?

  • [x] I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR!

I work extensively with Go in systems and protocol-level projects (such as edio, gitingo, implementing HTTP over TCP and several other api and cli based projects).

Having been actively contributing to this generator monorepo across our test suites, core generator, templates and CI, I am volunteering to implement this template and help look after it long term; handling issues, reviewing community PRs, and keeping it aligned with future generator and spec updates.

I'm looking forward to hear your thoughts and feedback on this proposal!

devxdh avatar Nov 11 '26 15:11 devxdh

@derberg @Adi-204 please have a look.

devxdh avatar Nov 11 '26 16:11 devxdh