openimsdk / protocol

Apache License 2.0
13 stars 43 forks source link

[Other]: gen.cmd failed #39

Closed zhaolibo1989 closed 2 weeks ago

zhaolibo1989 commented 10 months ago

What would you like to share?

I use gen.cmd to generate *.go, but get errors as follow:

D:\work\code\OpenIMSDK\protocol>protoc --go_out=plugins=grpc:./conversation --go_opt=module=github.com/OpenIMSDK/protocol/conversation conversation/conversation.proto
--go_out: protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC

See https://grpc.io/docs/languages/go/quickstart/#regenerate-grpc-code for more information.

D:\work\code\OpenIMSDK\protocol>protoc --version
libprotoc 22.0

D:\work\code\OpenIMSDK\protocol>protoc-gen-go --version
protoc-gen-go v1.29.1

D:\work\code\OpenIMSDK\protocol>protoc-gen-go-grpc --version
protoc-gen-go-grpc 1.3.0

D:\work\code\OpenIMSDK\protocol>

Additional information

I use 'protoc --go-grpc_out=...' to generate gRPC, and then, failed again.

D:\work\code\OpenIMSDK\protocol>protoc --go-grpc_out=plugins=grpc:./conversation --go_opt=module=github.com/OpenIMSDK/protocol/conversation conversation/conversation.proto
Unknown flag: --go_opt
zhaolibo1989 commented 10 months ago

https://www.cnblogs.com/yanweifeng/p/17485496.html

zhaolibo1989 commented 10 months ago

https://www.cnblogs.com/yanweifeng/p/17485496.html

使用go install github.com/golang/protobuf/protoc-gen-go后,protoc-gen-go不能单独查看版本号。

C:\Users\Administrator>protoc-gen-go --version
protoc-gen-go: unknown argument "--version" (this program should be run by protoc, not directly)

生成的 *.go 中提示的 protoc-gen-go 版本有变化。

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
//  protoc-gen-go v1.31.0 ****这里原来是 v1.29.1
//  protoc        v4.22.0
// source: conversation/conversation.proto

试图 go install 指定 v1.29.1 版本号安装时,提示没有这个版本。如何控制这个版本,原文件的 v1.29.1 版本是哪里来的?

C:\Users\Administrator>go install github.com/golang/protobuf/protoc-gen-go@v1.29.1
go: github.com/golang/protobuf/protoc-gen-go@v1.29.1: github.com/golang/protobuf/protoc-gen-go@v1.29.1: invalid version: unknown revision protoc-gen-go/v1.29.1

使用 v1.31.0 版本的 protoc-gen-go 生成的 go 文件对 protocol 的使用有什么影响?

gch2008net commented 1 month ago

got it

mo3et commented 2 weeks ago

I have also encountered this problem.

I solve to use go install github.com/golang/protobuf/protoc-gen-go@latest. It work it.

So anyone have this problem. You can refer to the article mentioned in the previous comment.

mo3et commented 2 weeks ago

https://www.cnblogs.com/yanweifeng/p/17485496.html

使用go install github.com/golang/protobuf/protoc-gen-go后,protoc-gen-go不能单独查看版本号。

C:\Users\Administrator>protoc-gen-go --version
protoc-gen-go: unknown argument "--version" (this program should be run by protoc, not directly)

生成的 *.go 中提示的 protoc-gen-go 版本有变化。

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
//    protoc-gen-go v1.31.0 ****这里原来是 v1.29.1
//    protoc        v4.22.0
// source: conversation/conversation.proto

试图 go install 指定 v1.29.1 版本号安装时,提示没有这个版本。如何控制这个版本,原文件的 v1.29.1 版本是哪里来的?

C:\Users\Administrator>go install github.com/golang/protobuf/protoc-gen-go@v1.29.1
go: github.com/golang/protobuf/protoc-gen-go@v1.29.1: github.com/golang/protobuf/protoc-gen-go@v1.29.1: invalid version: unknown revision protoc-gen-go/v1.29.1

使用 v1.31.0 版本的 protoc-gen-go 生成的 go 文件对 protocol 的使用有什么影响?

you can find version in here. also everyone package you can find in pkg.go.dev.

So I have to answer the question. First, update protoc-gen-go usually is not breaking change. It is not problem. Just use proto file generate corresponding go file. So you worry the version.