zoukankan      html  css  js  c++  java
  • go-micro 1.0框架升级到2.0所遇到的问题

      这里有官方的升级指导一份 https://mp.weixin.qq.com/s/XWf_my36Z7k3lfOySja3Sg
      
      这里着重要说的是api类型的proto 处理,这里有一个样例:

      

    环境:

    micro version 2.2.0
    go version go1.14 darwin/amd64
    go mod模式
    github.com/micro/protoc-gen-micro/v2 包
    `micro new --type=api example` 生成的项目


    第一步:更改proto文件(proto/example/example.proto)import引入包

    `import "github.com/micro/go-micro/v2/api/proto/api.proto";`
    改为
    `import "github.com/micro/go-micro/api/proto/api.proto";`

    第二步:更改Makefile文件

    `protoc --proto_path=. --micro_out=. --go_out=. proto/example/example.proto`
    改为
    `protoc --proto_path=${GOPATH}/src:. --go_out=. --micro_out=Mgithub.com/micro/go-micro/api/proto/api.proto=${GOPATH}/src/github.com/micro/go-micro/v2/api/proto:. proto/example/example.proto`

    第三步:下载go-micro包

    在`${GOPATH}/src/github.com/micro` 目录下使用命令`git clone git@github.com:micro/go-micro.git` 下载go-micro包


    提示:
    1、根据自己项目名称替换以上的example
    2、第三步操作不能使用`go get github.com:micro/go-micro`命令

    proto文件生成好了就可以写字节的逻辑或者编译了

      

      

  • 相关阅读:
    小数化分数2
    Sum of divisors
    Subsequence
    Lowest Bit
    Specialized Four-Digit Numbers
    Hunters
    Pet
    测试你是否和LTC水平一样高
    Bank Interest
    bzoj 1295
  • 原文地址:https://www.cnblogs.com/huronghuan/p/12527641.html
Copyright © 2011-2022 走看看