Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timrutte/go-grpc-api-template
Go template for building a gRPC API microservice with REST support, showcasing best practices and a clean project structure.
https://github.com/timrutte/go-grpc-api-template
api go golang grpc template-project
Last synced: about 1 month ago
JSON representation
Go template for building a gRPC API microservice with REST support, showcasing best practices and a clean project structure.
- Host: GitHub
- URL: https://github.com/timrutte/go-grpc-api-template
- Owner: TimRutte
- Created: 2024-10-28T13:02:34.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-30T13:04:59.000Z (3 months ago)
- Last Synced: 2024-12-17T00:13:39.484Z (about 1 month ago)
- Topics: api, go, golang, grpc, template-project
- Language: Go
- Homepage:
- Size: 96.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gRPC API Template
This repository provides a template for implementing a gRPC API in Go, which can also be accessed via REST. It demonstrates a well-structured project layout that adheres to best practices in Go development.
## Table of Contents
- [Features](#features)
- [Project Structure](#project-structure)
- [Getting Started](#getting-started)
- [Building and Running](#building-and-running)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)## Features
- **gRPC API**: Fast and efficient remote procedure calls.
- **RESTful Access**: Access the same functionality through RESTful endpoints.
- **Best Practices**: Organized project structure for maintainability and scalability.
- **Integrated Testing**: Unit and integration tests to ensure code quality.
- **Protobuf Definitions**: Clear and structured API definitions using Protocol Buffers.## Getting Started
### Prerequisites
- Go 1.18 or later
- Protobuf compiler (`protoc`)
```bash
brew install protobuf # for mac
```
```bash
pip install protobuf # for linux
```
- gRPC and related Go libraries
```bash
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest
```
- Pre-commit
```bash
brew install pre-commit # for mac
```
```bash
pip install pre-commit # for linux
```### Installation
1. Clone the repository:
```bash
git clone https://github.com/TimRutte/api.git
cd api
```2. Install dependencies:
```bash
make tidy
```3. Install necessary Go tools:
```bash
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
```## Building and Running
To build and run the application, use the following commands:
```bash
make build-linux
```
```bash
make build-darwin
```
```bash
make build-windows
``````bash
make run
```### Docker
To run the application in a Docker container, build the image:
```bash
make docker-build
```Then run the container:
```bash
make docker-run
```## Testing
Unit tests and integration tests are included in the project. To run the tests with vulnerability check, use:
```bash
make test
```To run only the unit tests:
```bash
make test-only
```## Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.