Skip to content

protoc-gen-go: generate MarshalBinary/UnmarshalBinary methods for messages #210

Open
@phifty

Description

@phifty

If the generated code would include the methods MarshalBinary and UnmarshalBinary from Go's stdlib, the corresponding interfaces from the encoding package would be satisfied. Storage/Transmitting-Code could be unified and a dependency to the protobuf package could be removed. The methods would look like:

func (m *Model) MarshalBinary() ([]byte, error) {
    return proto.Marshal(m)
}

func (m *Model) UnmarshalBinary(data []byte) error {
    return proto.Unmarshal(data, m)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    generator-proto-optioninvolves generators respecting a proto option to control generated source outputproposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions