Home > Backend Development > Golang > Detailed explanation of how to build grpc environment in go language

Detailed explanation of how to build grpc environment in go language

藏色散人
Release: 2020-08-17 13:28:01
forward
3093 people have browsed it

The following column Golang Language Tutorial will introduce to you how to build the go language grpc environment. I hope it will be helpful to friends in need!

Detailed explanation of how to build grpc environment in go language

Installing grpc:
The command given by the official website is:

go get -u google.golang.org/grpc
Copy after login

It seems that it can’t be used, it can’t connect to the server, even if I hang up xxx It's useless. I have no choice but to install it in a roundabout way. Anyway, the code is available on github, so I clone it from github.

# 下载grpc-go
git clone https://github.com/grpc/grpc-go.git %GOPATH%/src/google.golang.org/grpc

# 下载golang/net
git clone https://github.com/golang/net.git %GOPATH%/src/golang.org/x/net

# 下载golang/text
git clone https://github.com/golang/text.git %GOPATH%/src/golang.org/x/text

# 下载go-genproto
git clone https://github.com/google/go-genproto.git %GOPATH%/src/google.golang.org/genproto

# 安装
cd $GOPATH/src/go install google.golang.org/grpc
Copy after login

At this time, a lot of errors will be reported because there are still a few missing packages. What is protobuf

git clone https://e.coding.net/robinqiwei/googleprotobuf.git %GOPATH%/src/google.golang.org/protobuf
Copy after login

clone is to complete protobuf and then you execute

go install google.golang.org/grpc
Copy after login

to succeed!

Something special to note
There must be a go.mod file
In addition, grpc cannot be automatically loaded when I write the client. I don’t know what the hell is going on?
"google.golang.org/grpc" is written into the import, and then the command line is executed

go mod tidy
Copy after login

and it is automatically downloaded. Didn't I clone it before? No matter, it can be used normally anyway!

For more golang technical articles, please visit the golang tutorial column!

The above is the detailed content of Detailed explanation of how to build grpc environment in go language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template