Error go: module github.com/golang/protobuf is deprecated: Use the "google.golang.org/protobuf" module instead

huangapple go评论99阅读模式
英文:

Error go: module github.com/golang/protobuf is deprecated: Use the "google.golang.org/protobuf" module instead

问题

我从.proto文件生成golang代码后遇到了一个错误。

我在stackoverflow上搜索后尝试了以下命令:

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

然后我得到了以下错误信息:

点击这里查看错误信息

点击这里查看生成的代码

英文:

I am facing an error after generating the code in golang from .proto file

enter image description here

I tried this line after searching in stackoverflow :

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

and I get :

enter image description here

答案1

得分: 1

找到了,这是在 ~/.bashrc 文件中的设置问题,我没有准确指定 GOROOT 和 GOPATH。以下是要遵循的步骤:

在命令行中执行以下命令:

nano ~/bashrc

然后将以下行添加到文件中:

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

export GOPATH=/home/user/golib
export PATH=$PATH:$GOPATH/bin
export GOPATH=$GOPATH:/home/user/code

点击 ctrl^X 保存文件。

所有的依赖项将被添加到 golib 文件夹中。

然后注销当前会话。

顺便说一下,我是按照 freecodecamp 在 YouTube 上的视频指导进行操作的。

英文:

found it,
it was a setup issue in the ~/.bashrc file I didn't specify exactly the GOROOT & GOPATH
here's the steps to follow

on your command line

nano ~/bashrc

then add this lines to the file

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

export GOPATH=/home/user/golib
export PATH=$PATH:$GOPATH/bin
export GOPATH=$GOPATH:/home/user/code

save it by clicking ctrl^X

all the dependencies will be added ;as I did understand ; to the golib folder

then logout your session

by the way I followed the instructions from freecodecamp video on YouTube

答案2

得分: -1

我认为你应该运行以下命令:

go install google.golang.org/protobuf/cmd

并使用它生成你的代码。

附注:安装完成后,二进制文件将被放置在 $GOPATH/bin 目录下。

英文:

I think you should run

go install google.golang.org/protobuf/cmd

and generate your code using it.

P.S. after installation the binary will be put to $GOPATH/bin

huangapple
  • 本文由 发表于 2022年2月12日 18:20:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/71090982.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定