Skip to content

Proto3 repeated field not packed by default #197

Closed
@cygery

Description

@cygery

Message definitions

proto3_test.proto:

syntax = "proto3";

package test;

message Test3Int32RepDefault {
    repeated int32 repeated_int32 = 1;
}

message Test3Int32RepPackedTrue {
    repeated int32 repeated_int32 = 1 [packed = true];
}

Compiled via:

$ protoc --version
libprotoc 3.0.0
$ protoc --go_out=. *.proto

Result

proto3_test.pb.go:

// ...
type Test3Int32RepDefault struct {
    RepeatedInt32 []int32 `protobuf:"varint,1,rep,name=repeated_int32,json=repeatedInt32" json:"repeated_int32,omitempty"`
}
// ...
type Test3Int32RepPackedTrue struct {
    RepeatedInt32 []int32 `protobuf:"varint,1,rep,packed,name=repeated_int32,json=repeatedInt32" json:"repeated_int32,omitempty"`
}
// ...

The repeated field with default packed setting compiles to a non-packed field although it should be packed by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions