https://github.com/ironcore864/go-nats-pub-sub-example
https://github.com/ironcore864/go-nats-pub-sub-example
Last synced: 26 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/ironcore864/go-nats-pub-sub-example
- Owner: IronCore864
- Created: 2019-12-16T13:12:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-12-17T12:43:29.000Z (over 6 years ago)
- Last Synced: 2025-10-31T03:41:29.573Z (9 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NATS Simple Pub/Sub Usage with Golang
## Build Locally
Change user/pass for nats accordingly in the `main.go` files, then run:
```
cd go-nats-pub && go build .
cd ../go-nats-sub && go build .
```
## Run
```
export USER=xxx
export PASS=yyy
export NATS_HOST=zzz(only host name here, no protocol, no port)
cd go-nats-sub && ./go-nats-sub
```
In another terminal:
```
export USER=xxx
export PASS=yyy
cd go-nats-pub && ./go-nats-pub
```
Should see logs from 1st tab from the subscriber.
## Docker Build
Change user/pass for nats accordingly in the `main.go` files, then run:
```
docker build . -t ironcore864/go-nats
```
When running this image, subscriber is started. You can execute the publisher accordingly.