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
setup
GitHub Action gets triggered. It essentially leaves aPR
when it is done. - Merge the
PR
namedInitial Setup
. - When the
PR
is done merged, it triggers anotherci
GitHub 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.go
files 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.go
andcmd/server/main.go
to check if there is any errors. -
cmd/client
is for launching Client application. Boilerplate codes for sending outDummyService
'sGetHello
rpc is provided. -
cmd/server
is for launching Server application. Boilerplate codes for set Server and listening on a specific port is provided. -
cmd/tools
is for listing up any go packages to be included. Boilerplate codes list upprotoc-gen-go-grpc
andprotoc-gen-go
. -
internal
is an empty as in the initial setup. You can store any business logics for any internal use here. -
model
is an empty as in the initial setup. You can store any models to work with internal business logics here. -
pkg/pbs
contains protocol buffer related stuff. Usually files with the extensions of*.proto
,*.pb.go
should be stored in here. -
pkg/serv
is there to handle incoming messages from client to server. -
Makefile
mainly provides two rules, installing gRPC/protobuf environment viamake install
and generating protobuf into the appropriate folderpkg/pbs
viamake all
.