Use of GRPC in Golang (client)

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

Installing GRPC

Use the following command for GRPC installation:

go get google.golang.org/grpc

Installing Protocol buffers v3

Install the protocol compiler used to generate the GRPC service code. The easiest way to do this is to download a binary compression package in https://github.com/google/protobuf/releases. Add the environment variable after decompression, as follows:

export PATH=$PATH:执行路径 (linux下)set PATH=%PATH%;执行路径   (windows下)

Install the Protocol plug-in by executing the following command:

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

New file "Helloworld.proto", fill in the following content:

syntax = "proto3";package helloworld;// 服务端定义service Greeter {// 服务端返馈信息方法rpc SayHello (HelloRequest) returns (HelloReply) {}}// 包含用户名的请求信息message HelloRequest {string name = 1;}// 服务端响应信息message HelloReply {string message = 1;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.