Coder Social home page Coder Social logo

go-grpc's Introduction

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

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

export PATH="$PATH:$(go env GOPATH)/bin"

2. Project dependencies

go mod tidy
go mod vendor

3. MySQL

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

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

cd cmd/server && go run main.go

6. Run gRPC client

cd cmd/client && go run main.go

License

MIT ยฉ Cuong Nguyen 2024

go-grpc's People

Contributors

cuongndc avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.