https://github.com/cuongndc9/go-grpc
go 🤝 gRPC
https://github.com/cuongndc9/go-grpc
103cuong go golang grpc hacktoberfest
Last synced: over 1 year ago
JSON representation
go 🤝 gRPC
- Host: GitHub
- URL: https://github.com/cuongndc9/go-grpc
- Owner: cuongndc9
- License: mit
- Created: 2020-08-23T12:00:20.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-17T11:18:34.000Z (over 2 years ago)
- Last Synced: 2024-11-04T02:58:31.047Z (over 1 year ago)
- Topics: 103cuong, go, golang, grpc, hacktoberfest
- Language: Go
- Homepage:
- Size: 2.67 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Not using GitHub? Find me on [LinkedIn](https://www.linkedin.com/in/cuong9/)!
# go-grpc
Go 🤝 gRPC
# 🧑💻 Project Structure
### api/
This directory contains gRPC definitions.
### cmd/
The cmd/ directory contains the main applications of the project. In this case, there are client and server directories.
### config/
The config/ directory holds configuration files such as environment or settings.
### model/
The model/ directory contains database entities.
### store/
The store/ directory contains sql logic for models. Eg: user store logics like queryProfile, editProfile. And it's related user model.
### module/
The module/ directory is collections of domain logic or features.
### pkg/
The pkg/ directory typically houses reusable packages or libraries that can be used across the project or potentially shared with other projects.
### proto/
This directory contains Protobuf files, which are used for defining gRPC services and messages.
### sql/
The sql/ directory contains SQL scripts, particularly release notes related to database schema changes or updates.
# 🐧 Commands
### 1. Local Machine
```shell script
brew install protobuf
protoc --version
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
```
#### .zshrc or.bashrc
```shell script
export PATH="$PATH:$(go env GOPATH)/bin"
```
### 2. Project dependencies
```shell script
go mod tidy
go mod vendor
```
### 3. MySQL
```shell script
docker run -it --name database -p 3306:3306 -e MYSQL_ROOT_PASSWORD=cuongpo -e MYSQL_DATABASE=cuongpo mysql:latest
```
### 4. Generate Go's protobuf code
```shell script
protoc --proto_path=proto \
--go_out=api --go_opt=paths=source_relative \
--go-grpc_out=api --go-grpc_opt=paths=source_relative,require_unimplemented_servers=false \
proto/*.proto
```
### 5. Run gRPC server
```shell script
cd cmd/server && go run main.go
```
### 6. Run gRPC client
```shell script
cd cmd/client && go run main.go
```
## License
MIT © [Cuong Nguyen](https://github.com/cuongnd9/) 2024