Skip to content

asyncapi-go-template 0.1.0

Install from the command line:
Learn more about npm packages
$ npm install @spiral/asyncapi-go-template@0.1.0
Install via package.json:
"@spiral/asyncapi-go-template": "0.1.0"

About this version

AsyncAPI logo

release tests release license

Overview

This template generates Go structures as a package for building event-driven applications.

Template Output

The go code generated by this template has the following structure:

  • channels.gen.go - contains all the channels defined in the AsyncAPI document.
  • payloads.gen.go - contains all the payloads.
  • servers.gen.go - contains servers addresses.
  • version.gen.go - contains version constants.

Watch the example output in the example directory.

Technical requirements

How to use the template

This template must be used with the AsyncAPI Generator. You can find all available options here.

Run the following command to generate a Go package

$ npm install -g @asyncapi/generator
# clone this repository and navigate to this repository
$ ag ./example/asyncapi.yaml ./ -o ./example/generated -p packageName=your_go_package_name

Following are the options that can be passed to the generator

  1. packageName: name of the go package to be generated

Docker usage

Additionally, you can use the docker image:

Registry Image
GitHub Container Registry ghcr.io/spiral/asyncapi-go-template

Using the latest tag for the docker image is highly discouraged because of possible backward-incompatible changes during major upgrades. Please, use tags in X.Y.Z format

$ docker run --rm -u "$(id -u):$(id -g)" -v "${PWD}:/host:rw" -w "/host" \
    ghcr.io/spiral/asyncapi-go-template ./example/asyncapi.yaml @spiral/asyncapi-go-template \
      -o ./example/generated \
      -p packageName=your_go_package_name \
      --force-write

In addition, the docker image contains installed @asyncapi/markdown-template and @asyncapi/html-template. You can use them to generate documentation for your AsyncAPI document.

Template configuration

You can configure this template by passing different parameters in the Generator CLI: -p PARAM1_NAME=PARAM1_VALUE -p PARAM2_NAME=PARAM2_VALUE

Name Description Required Example
packageName Name for the generated Go package false asyncapi

Releasing

New versions publishing is very simple - just make required changes in this repository, update changelog file and "publish" new release using repo releases page.

Docker image & npm package will be build and published automatically.

New release will overwrite the latest docker image tag.

Details


Assets

  • asyncapi-go-template-0.1.0.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all