go-micro - 安装及可能遇到的问题
<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">1、</span>安装</h1>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">1. 安装micro和go-micro的command line工具</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">以用于终端操作</p>micro的github:链接 <a style="color: black;">Getting Started with Micro | Micro</a>go-micro的github:链接 <a style="color: black;">GitHub - go-micro/cli: Go Micro comman</a>d line interface终端操作:
// micro
go install github.com/micro/micro/v3@latest
// go-micro
go install github.com/go-micro/cli/cmd/go-micro@latest<h1 style="color: black; text-align: left; margin-bottom: 10px;">2. 现有的go项目中引入安装</h1># 安装go-micro
go get -u -v github.com/micro/go-micro
# 安装工具
go get -u -v github.com/micro/micro
# 安装protobuf
go get -u google.golang.org/protobuf
go get -u github.com/micro/protoc-gen-micro<h1 style="color: black; text-align: left; margin-bottom: 10px;">3. docker中安装micro</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">按照</span>个人习惯吧,<span style="color: black;">倘若</span>适应了在docker的容器进行操作,<span style="color: black;">能够</span><span style="color: black;">运用</span>docker去pull micro的镜像,在容器中玩一下。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">我个人<span style="color: black;">日前</span>习惯于在服务器上<span style="color: black;">运用</span>docker去<span style="color: black;">安排</span>应用,本地<span style="color: black;">运用</span>docker桌面版来<span style="color: black;">研发</span>和测试。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">针对</span>本地进行go<span style="color: black;">研发</span>,<span style="color: black;">意见</span>直接<span style="color: black;">运用</span>1中的方式安装cli。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">详细</span>安装<span style="color: black;">过程</span>,直接看docker hub的官网:</p>micro:
<span style="color: black;">https://hub.docker.com/r/micro/micro</span><span style="color: black;">go-micro: </span><span style="color: black;">https://hub.docker.com/r/yam8511/go-micro</span><span style="color: black;"> (这个是star比较多的一个,暂无officail版的)</span>
<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">2、</span><span style="color: black;">检测</span>micro和go-micro</h1>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">1. 终端<span style="color: black;">检测</span>micro和go-micro命令<span style="color: black;">是不是</span>成功</h1>// <span style="color: black;">检测</span>micro,直接输入micro
micro
// <span style="color: black;">检测</span>go-micro,直接输入go-micro
go-micro<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">正常<span style="color: black;">状况</span>下<span style="color: black;">表示</span>:</span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-axegupay5k/97df1504c8b94990af5b366e216c61eb~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728814867&x-signature=3VhF2G1ppvoJzg0J6bzJA6PqEyU%3D" style="width: 50%; margin-bottom: 20px;"></div>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">2. 可能<span style="color: black;">显现</span>的问题:</h1><span style="color: black;">zsh: command not found: micro</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">处理</span><span style="color: black;">方法</span>:(需要把micro和go-micro的命令文件暴露给zsh终端)</span></p><span style="color: black;">进入自己的GOBIN配置目录,检查<span style="color: black;">是不是</span><span style="color: black;">已然</span>有了micro和go-micro的可执行文件,<span style="color: black;">通常</span><span style="color: black;">状况</span>下都会有的</span>// 获取GOBIN目录<span style="color: black;">或</span>GOPATH目录,GOPATH中的bin文件夹<span style="color: black;">通常</span>设置为GOBIN
go env GOBIN
// <span style="color: black;">或</span>在GOPATH下的bin目录中找
go env GOPATH<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-6w9my0ksvp/5118dc0815d74e43983a72af9a7eb820~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728814867&x-signature=%2FJGDotOMC9%2F2SvcHAV3D7z04EDU%3D" style="width: 50%; margin-bottom: 20px;"></div><span style="color: black;">既然<span style="color: black;">已然</span>有了这2个可执行文件,<span style="color: black;">那样</span>需要暴露一下可执行文件的路径,<span style="color: black;">因为</span>我<span style="color: black;">运用</span>的是zsh终端,<span style="color: black;">那样</span>配置文件<span style="color: black;">便是</span>我当前电脑用户下的.zshrc这个<span style="color: black;">隐匿</span>文件中。<span style="color: black;">那样</span>添加可执行文件的路径:</span>export PATH=${PATH}:$(go env GOPATH)/bin<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">截图</span></p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-6w9my0ksvp/b4509515c3b649c48eb99b5bdcd633fc~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1728814867&x-signature=02k2tCxU7P5saGK8mjy9XnH01hY%3D" style="width: 50%; margin-bottom: 20px;"></div><span style="color: black;">更新.zshrc文件, 之后再重担执行一下micro和go-micro命令验证一下<span style="color: black;">就可</span></span>// 终端执行一下命令,使配置生效
source .zshrc<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">后续再<span style="color: black;">弥补</span>.</span></p>
这篇文章真的让我受益匪浅,外链发布感谢分享! 外贸网站建设方法 http://www.fok120.com/ 同意、说得对、没错、我也是这么想的等。
页:
[1]