
Security News
npm Introduces minimumReleaseAge and Bulk OIDC Configuration
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.
go-template
Advanced tools
This template generates a Go module that uses watermill as the messaging middleware
Currently this template supports AMQP subscribers
This template must be used with the AsyncAPI Generator. You can find all available options here.
This template has been tested to generate an AMQP subscriber for this asyncapi.yaml file
npm install -g @asyncapi/generator
# clone this repository and navigate to this repository
ag test/asyncapi.yaml @asyncapi/go-watermill-template -o /path/to/generated-code -p moduleName=your-go-module-name
Following are the options that can be passed to the generator
The above code currently generates a Go module that has a AMQP subscriber.
To run the generated code the following needs to be installed
go mod download
go mod tidy
rabbitmq. It is hardcoded as "amqp://guest:guest@localhost:5672/" at <generated-code>/config/server.go. Change it as per your rabbitmq instance requirementsgo run main.go
rabbitmq, navigate to it using http://localhost:15672/ with username and password guest/ guest (These are default rabbitmq credentials).
FYI one can start an instance of rabbitmq using docker as follow
docker run -d -p 15672:15672 -p 5672:5672 rabbitmq:3-management
cURL request. Default rabbitmq user is guest and password is guest curl --user <rabbit-user>:<rabbit-password> -X PUT \
http://localhost:15672/api/queues/%2f/<queue-name> \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"auto_delete":false,
"durable":true
}'
cURL request. Default rabbitmq user is guest and password is guest curl --user <rabbit-user>:<rabbit-password> -X POST \
http://localhost:15672/api/exchanges/%2f/amq.default/publish \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d ' {
"properties":{},
"routing_key":"light/measured",
"payload":"{\"id\":1,\"lumens\":2,\"sentAt\":\"2021-09-21\"}",
"payload_encoding":"string"
}'
go run main.go was running and the published message should be printedYou 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 |
|---|---|---|---|
| moduleName | Name for the generated Go module | false | my-app |
FAQs
Template for generating Go module based on async api
The npm package go-template receives a total of 5 weekly downloads. As such, go-template popularity was classified as not popular.
We found that go-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.

Security News
AI agents are writing more code than ever, and that's creating new supply chain risks. Feross joins the Risky Business Podcast to break down what that means for open source security.

Research
/Security News
Socket uncovered four malicious NuGet packages targeting ASP.NET apps, using a typosquatted dropper and localhost proxy to steal Identity data and backdoor apps.