0.0.1 • Published 1 year ago

@tarampampam/asyncapi-go-template v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

AsyncAPI logo

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.

Technical requirements

Async API 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

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

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

NameDescriptionRequiredExample
packageNameName for the generated Go packagefalseasyncapi