這里有官方的升級指導一份 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文件生成好了就可以寫字節的邏輯或者編譯了