Sample of GRPC server written on go
You can skip this section if you do not want to change existing protobuf
- Install protobuf on your system
- Install
protoc-gen-go-grpc
for gogo install google.golang.org/protobuf/cmd/protoc-gen-go@latest
. This is used to generate client/server code for golang
Generate client, server golang code with command:
protoc --go_out=./gen --go_opt=paths=source_relative --go-grpc_out=./gen --go-grpc_opt=paths=source_relative ./proto/my_service.proto
You have to install go and sqlite3
Clone the project and install go packages
git clone https://github.com/Nikita-Filonov/sample_go_grpc_server`
cd ./sample_go_grpc_server
go mod download
Apply migrations
go install github.com/rubenv/sql-migrate/...@latest
sql-migrate up -config=./infrastructure/config.yml
Finally run the server
go run main.go
You can run project inside docker, make sure you have docker installed
git clone https://github.com/Nikita-Filonov/sample_go_grpc_server
cd ./sample_go_grpc_server
docker build . -t sample_go_grpc_server
docker run -p 8000:8000 sample_go_grpc_server
Apply migrations
docker ps
docker exec -it <container-id> sh
sql-migrate up -config=./infrastructure/config.yml
exit