Skip to content

sample reverse string tutorial to explain grpc between go server and go client/netcore2 client

Notifications You must be signed in to change notification settings

pastmaster007/samproto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is sample reverse string tutorial to explain grpc between go server and go client/netcore2 client..

It has following source code folders

  • go server
  • go client
  • netcore2 csharp client

Below instructions are only for macOS X. i assume below steps might also works for linux.

Prerequisites:

  1. Homebrew command line package manager utility
  2. Go lang compiler
  3. Python@2, which comes default with macOS X
  4. .Net core SDK, this project uses netcoreapp2.1
  5. protoc compiler
  6. grpc command line tool
  7. grpc_csharp_plugin command line plugin tool

Initial Approach:

Net core installation

goto https://www.microsoft.com/net/download download Build apps SDK x64 installer run installer

Go installation

gRPC requires Go 1.6 or higher.

$ go version

If go is not installed, you can install via Homebrew package manager and setup path variables. Ref: https://stackoverflow.com/a/40129734

brew install go
export GOPATH=$HOME/.golang
export PATH=$PATH:$GOPATH/bin

Install gRPC

Use the following command to install gRPC.

$ go get -u google.golang.org/grpc

Install Protocol Buffers v3

Ref: http://google.github.io/proto-lens/installing-protoc.html

brew install protobuf

Next, install the protoc plugin for Go

$ go get -u github.com/golang/protobuf/protoc-gen-go

Clone repository

git clone https://github.com/pastmaster007/samproto
cd samproto

#compile proto file into pb.go file
protoc -I ./sample ./sample/sample.proto --go_out=plugins=grpc:./sample

# run go server
go run ./goserver/main.go

open another tab in terminal

# run go client
go run ./goclient/main.go

open anothet tab in terminal for net core client

cd netcoreclient
dotnet run

steps to initiate new net core app from command line

# creates new dotnet console app
dotnet new console

# add required packages to compile and run
dotnet add package Google.Protobuf

dotnet add package Grpc

# add required packages to compile, after package download we can remove this package reference from .csproj file.
dotnet add package grpc.tools

# generates grpc files using proto file.
# make sure "protoc-gen-grpc" plugin requires full file path
~/.nuget/packages/grpc.tools/1.15.0/tools/macosx_x64/protoc \
-I../sample --csharp_out . --grpc_out . ../sample/sample.proto \
--plugin=protoc-gen-grpc=/Users/swx/.nuget/packages/grpc.tools/1.15.0/tools/macosx_x64/grpc_csharp_plugin 

Refs:

About

sample reverse string tutorial to explain grpc between go server and go client/netcore2 client

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published