Example of gRPC with Go
--go_outspecifies out directory for generation all entities "messages of.protofile"
--go-grpc_outspecifies out directory for generation all gRPC code "services of.protofile"
latest paramspecifies directory for get.protofile
protoc --go_out=. --go-grpc_out=. proto/course_category.protoThe client used for tests is named evans
# MacOS installation using brew
brew tap ktr0731/evans
brew install evans# For connect on database
sqlite3 db.sqlite-- For create table categories
create table categories(
id string primary key,
name string,
description string
);
-- For create table courses
create table courses(
id string primary key,
name string,
description string,
category_id string,
foreign key (category_id) references categories(id)
);go run cmd/grpcServer/main.goBy default the evans client listens on TCP port 50051, you don't need to specify if you are using this port
evans -r replNeeds to start client before selecting gRPC service
first paramis the gRPC service name
# If your function uses stream mode, for stop this use 'Ctrl + D'
service CategoryServiceNeeds to start client before selecting gRPC service
first paramis the function name
call CreateCategory