gogo / protobuf

[Deprecated] Protocol Buffers for Go with Gadgets
Other
5.65k stars 810 forks source link

panic: marshaler does not support group field in proto2 #311

Open wpecker opened 6 years ago

wpecker commented 6 years ago

The proto file as below:

syntax = "proto2";

package pbdata;

message ValueType {
    optional int32 int_type =1;
    optional int64 long_type = 2;
    optional float float_type = 3;
    optional string string_type =4;
}

message Log {
    required int64 log_timestamp =1;
    optional string ip = 2;
    optional group Field  = 3 {
        repeated group Map = 1 {
            required string key = 1;
            optional ValueType value = 2;
        }
    }
}

protoc --gofast_out=. cct.pb.proto

panic: marshaler does not support group Field

goroutine 1 [running]:
github.com/gogo/protobuf/plugin/marshalto.(*marshalto).generateField(0xc420078000, 0x0, 0x864da0, 0xc4200ea268, 0xc420012090, 0xc420079220, 0xc4200b29a0)
    /mnt/shared/go-T/src/github.com/gogo/protobuf/plugin/marshalto/marshalto.go:848 +0x13de3
github.com/gogo/protobuf/plugin/marshalto.(*marshalto).Generate(0xc420078000, 0xc420012090)
    /mnt/shared/go-T/src/github.com/gogo/protobuf/plugin/marshalto/marshalto.go:1310 +0x2a2e
github.com/gogo/protobuf/protoc-gen-gogo/generator.(*Generator).runPlugins(0xc42007aa00, 0xc420012090)
    /mnt/shared/go-T/src/github.com/gogo/protobuf/protoc-gen-gogo/generator/generator.go:1226 +0x5c
github.com/gogo/protobuf/protoc-gen-gogo/generator.(*Generator).generate(0xc42007aa00, 0xc420012090)
    /mnt/shared/go-T/src/github.com/gogo/protobuf/protoc-gen-gogo/generator/generator.go:1282 +0x399
github.com/gogo/protobuf/protoc-gen-gogo/generator.(*Generator).GenerateAllFiles(0xc42007aa00)
    /mnt/shared/go-T/src/github.com/gogo/protobuf/protoc-gen-gogo/generator/generator.go:1212 +0x25b
github.com/gogo/protobuf/vanity/command.Generate(0xc42004c0c0, 0x1)
    /mnt/shared/go-T/src/github.com/gogo/protobuf/vanity/command/command.go:131 +0x244
main.main()
    /mnt/shared/go-T/src/github.com/gogo/protobuf/protoc-gen-gofast/main.go:46 +0x10a
--gofast_out: protoc-gen-gofast: Plugin failed with status code 2.
awalterschulze commented 6 years ago

group has been deprecated for years and years. So years ago 2012 when this was already deprecated I decided it was not worth the effort to support it in every plugin. I welcome a pull request and will provide guidance, if you would like to add support for group.

awalterschulze commented 6 years ago

Why not simply use a message instead of a goup?

wpecker commented 6 years ago

OK, thanks , i know , i have been use version proto3

awalterschulze commented 6 years ago

proto2 is fine, but group specifically has been deprecated for a while. Is there some reason you want to use group instead of message?

wpecker commented 6 years ago

@awalterschulze Thanks.

The company's old project or use a large number of proto2, can not switch to proto3 within a short time

awalterschulze commented 6 years ago

Message is still in proto 2. You don't have to switch to proto 3

On Sat, 22 Jul 2017, 14:18 Kent.Xiao, notifications@github.com wrote:

@awalterschulze https://github.com/awalterschulze Thanks.

The company's old project or use a large number of proto2, can not switch to proto3 within a short time

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/gogo/protobuf/issues/311#issuecomment-317179959, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvsLTO0H5gI-SJVfX_l-i_-Gb7nKT-gks5sQeiMgaJpZM4OfUJW .

wpecker commented 6 years ago

@awalterschulze Temporarily unable to switch all project to proto3 version, just want to use gofast_out to improve performance.

awalterschulze commented 6 years ago

Again you don't need to switch to proto3

I am propsing this

syntax = "proto2";

package pbdata;

message ValueType {
    optional int32 int_type =1;
    optional int64 long_type = 2;
    optional float float_type = 3;
    optional string string_type =4;
}

message Log {
    required int64 log_timestamp =1;
    optional string ip = 2;
    optional message Field  = 3 {
        repeated message Map = 1 {
            required string key = 1;
            optional ValueType value = 2;
        }
    }
}

Only changing your groups to messages.

wpecker commented 6 years ago

@awalterschulze Thanks, I have checked, there are mistakes:

cct1.pb.proto:15:37: Expected ";".
cct1.pb.proto:23:1: Reached end of input in message definition (missing '}').

line 15 is optional message Field = 3 {

awalterschulze commented 6 years ago

Ok sorry my bad What about?


syntax = "proto2";

package pbdata;

message ValueType {
    optional int32 int_type =1;
    optional int64 long_type = 2;
    optional float float_type = 3;
    optional string string_type =4;
}

message Log {
    required int64 log_timestamp =1;
    optional string ip = 2;
    message FieldMsg {
        message MapMsg {
            required string key = 1;
            optional ValueType value = 2;
        }
        repeated MapMsg Map = 1;
    }
    optional FieldMsg Field = 3;
}
wpecker commented 6 years ago

@awalterschulze Great! Thanks

awalterschulze commented 6 years ago

My pleasure. Even though your issue is solved, I think we can still keep the issue open, since gogo protobuf still does not support groups.