Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of xxx is deprecated in go get

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to solve the problem of xxx is deprecated in go get". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to solve the problem of xxx is deprecated in go get"!

Recently, in learning grpc of go, you need to use protobuf,protoc-gen-go package to generate the protobuf version of golang protocol code.

Under the mac development environment, an error will be reported when installing the package using the following command

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

The error report is as follows:

After the error message is the go1.17 version, it is not recommended to use go get to install the package, but to install the package through go install

Here I use my personal solution.

Go to golang/protobuf to download the source code

Enter the protobuf directory

Enter the protoc-gen-go directory

Run the command go build

Run the command go install

Here's a brief introduction to go build and go install.

Go build

Through go build plus the name of the Go source file to be compiled, we can get an executable file with the name of the source file without the .go suffix by default.

Go install

Compared with the build command, the install command also installs the executable or library files to the agreed directory after compiling the source code.

The executable file compiled by go install is named after the directory name (DIR) in which it resides

Go install installs the executable file to the bin directory at the same level as src, and the bin directory is automatically created by go install

Go install compiles the various package that the executable depends on and places them in the pkg directory at the same level as src

At this point, the executable file of protoc-gen-go exists in the / bin directory of GOPATH.

Add the $GOPATH/bin directory to the environment variable so that subsequent commands generated by go install can be executed directly.

At this point, edit / etc/profile file to add this text to the profile file. The $GOPATH variable here is the GOPATH path of your local GO.

Export PATH= "$PATH:$GOPATH/bin" > > / etc/profile

Then the problem is solved! You can use the command protoc-- go_out=plugins=grpc:. * .proto exports the protocbuf protocol code of golang

At this point, I believe you have a deeper understanding of "how to solve the problem of xxx is deprecated in go get". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report