This repository provides server & client boilerplate codes written in golang. The server & client communicated via gRPC/protobuf interface. It's boring to fork the repo and replace all the placeholders to fit your own environment. Instead, this repository give an easy way to "copy".
- Click "Use this template" button.
- Fill up the name of repository that you want to create.
- When the repository is copied over to your place, a
setupGitHub Action gets triggered. It essentially leaves aPRwhen it is done. - Merge the
PRnamedInitial Setup. - When the
PRis done merged, it triggers anotherciGitHub Action. Wait until it ends. - Run
make install. You can also specify PROTOC_VERSION if needed like this:PROTOC_VERSION=3.17.0 make install
You can simply ping from a client to server with a dummy message via DummyService.
- Simply define your own protocol buffer services and messages in
/pkg/pbs/. - Generate
*.pb.gofiles viamake clean install all. - Implement your message receiving logic in
/pkg/serv/. - Write your own business logic to leverage your own gRPC/protobuf services and messages.
|-- .github -- (D)(0)
|
|-- cmd
| |-- client -- (D)(1)
| |
| |-- server -- (D)(2)
| |
| `-- tools -- (D)(3)
|
|
|-- internal -- (D)(4)
|
|-- model -- (D)(5)
|
|-- pkg
| |-- pbs -- (D)(6)
| |
| `-- serv -- (D)(7)
|
`-- Makefile -- (F)(8)
(D) indicates Directory, and (F) indicated File
-
Any GitHub Action should go into
.github. Basic CI workflow is provided. It simply buildscmd/client/main.goandcmd/server/main.goto check if there is any errors. -
cmd/clientis for launching Client application. Boilerplate codes for sending outDummyService'sGetHellorpc is provided. -
cmd/serveris for launching Server application. Boilerplate codes for set Server and listening on a specific port is provided. -
cmd/toolsis for listing up any go packages to be included. Boilerplate codes list upprotoc-gen-go-grpcandprotoc-gen-go. -
internalis an empty as in the initial setup. You can store any business logics for any internal use here. -
modelis an empty as in the initial setup. You can store any models to work with internal business logics here. -
pkg/pbscontains protocol buffer related stuff. Usually files with the extensions of*.proto,*.pb.goshould be stored in here. -
pkg/servis there to handle incoming messages from client to server. -
Makefilemainly provides two rules, installing gRPC/protobuf environment viamake installand generating protobuf into the appropriate folderpkg/pbsviamake all.