feat: first
This commit is contained in:
68
README.md
Normal file
68
README.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# Go gRPC Gateway Template
|
||||
|
||||
A simplified Go project template for gRPC services with HTTP/JSON gateway support, based on the [Go Standard Project Layout](https://github.com/golang-standards/project-layout).
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
├── cmd/server/ # Main application entry point
|
||||
├── internal/
|
||||
│ ├── handler/ # gRPC and gateway handlers
|
||||
│ └── service/ # Business logic
|
||||
├── pkg/pb/ # Generated protobuf files (auto-generated)
|
||||
├── api/v1/ # Protocol buffer definitions
|
||||
└── justfile # Task runner configuration
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Go 1.21+
|
||||
- Protocol Buffers compiler (`protoc`)
|
||||
- [just](https://github.com/casey/just) task runner
|
||||
- [nushell](https://www.nushell.sh/) (for justfile execution)
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. Install dependencies:
|
||||
```bash
|
||||
just deps
|
||||
```
|
||||
|
||||
2. Generate protobuf files:
|
||||
```bash
|
||||
just proto
|
||||
```
|
||||
|
||||
3. Build and run the server:
|
||||
```bash
|
||||
just dev
|
||||
```
|
||||
|
||||
## Available Commands
|
||||
|
||||
- `just proto` - Generate protobuf files
|
||||
- `just build` - Build the server binary
|
||||
- `just run` - Run the server
|
||||
- `just dev` - Full development workflow (deps + proto + run)
|
||||
- `just test` - Run tests
|
||||
- `just lint` - Run linter
|
||||
- `just clean` - Clean build artifacts
|
||||
|
||||
## API Endpoints
|
||||
|
||||
The server runs on two ports:
|
||||
- gRPC server: `:8080`
|
||||
- HTTP gateway: `:8081`
|
||||
|
||||
### Example HTTP endpoints:
|
||||
- `GET /v1/examples` - List all examples
|
||||
- `POST /v1/examples` - Create a new example
|
||||
- `GET /v1/examples/{id}` - Get a specific example
|
||||
|
||||
## Monorepo Integration
|
||||
|
||||
This template is designed to be integration-friendly for monorepo structures by:
|
||||
- Excluding shared proto folders
|
||||
- Using internal packages for service-specific logic
|
||||
- Minimal external dependencies
|
||||
- Clear separation of concerns
|
||||
Reference in New Issue
Block a user