2026-02-04 14:12:59 +00:00
|
|
|
# Go Micro Examples
|
|
|
|
|
|
|
|
|
|
This directory contains runnable examples demonstrating various go-micro features and patterns.
|
|
|
|
|
|
|
|
|
|
## Quick Start
|
|
|
|
|
|
|
|
|
|
Each example can be run with `go run .` from its directory.
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
### [hello-world](./hello-world/)
|
|
|
|
|
Basic RPC service demonstrating core concepts:
|
|
|
|
|
- Service creation and registration
|
|
|
|
|
- Handler implementation
|
|
|
|
|
- Client calls
|
|
|
|
|
- Health checks
|
|
|
|
|
|
|
|
|
|
**Run it:**
|
|
|
|
|
```bash
|
|
|
|
|
cd hello-world
|
|
|
|
|
go run .
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### [web-service](./web-service/)
|
|
|
|
|
HTTP web service with service discovery:
|
|
|
|
|
- HTTP handlers
|
|
|
|
|
- Service registration
|
|
|
|
|
- Health checks
|
2026-02-04 14:14:41 +00:00
|
|
|
- JSON REST API
|
2026-02-04 14:12:59 +00:00
|
|
|
|
|
|
|
|
**Run it:**
|
|
|
|
|
```bash
|
|
|
|
|
cd web-service
|
|
|
|
|
go run .
|
|
|
|
|
```
|
|
|
|
|
|
2026-02-04 14:14:41 +00:00
|
|
|
## Coming Soon
|
2026-02-04 14:12:59 +00:00
|
|
|
|
2026-02-04 14:14:41 +00:00
|
|
|
The following examples are planned:
|
2026-02-04 14:12:59 +00:00
|
|
|
|
2026-02-04 14:14:41 +00:00
|
|
|
- **pubsub-events** - Event-driven architecture with NATS
|
|
|
|
|
- **grpc-integration** - Using go-micro with gRPC
|
|
|
|
|
- **production-ready** - Complete production-grade service with observability
|
2026-02-04 14:12:59 +00:00
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
|
|
Some examples require external dependencies:
|
|
|
|
|
|
|
|
|
|
- **NATS**: `docker run -p 4222:4222 nats:latest`
|
|
|
|
|
- **Consul**: `docker run -p 8500:8500 consul:latest agent -dev -ui -client=0.0.0.0`
|
|
|
|
|
- **Redis**: `docker run -p 6379:6379 redis:latest`
|
|
|
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
|
|
To add a new example:
|
|
|
|
|
|
|
|
|
|
1. Create a new directory
|
|
|
|
|
2. Add a descriptive README.md
|
|
|
|
|
3. Include working code with comments
|
|
|
|
|
4. Add to this index
|
|
|
|
|
5. Ensure it runs with `go run .`
|
|
|
|
|
|