Skip to content

Implement custom options #179

@kerinin

Description

@kerinin

Custom option types appear to be broken - generated types do not implement ExtensionMap. Example protobuf definition:

syntax = "proto3";

import "google/protobuf/descriptor.proto";

extend google.protobuf.MessageOptions {
  string foo = 50001;
}


message MyMessage {
  option (foo) = "bar";
}

Attempting to access the option fails:

func main() {
    m := test.MyMessage{}

    ex, err = proto.GetExtension(&m, test.E_Foo)
    fmt.Printf("MyMessage.GetExtension: %+v, %+v\n", *ex.(*string), err)
}

// ./test.go:18: cannot use &m (type *test.MyMessage) as type proto.extendableProto in argument to proto.GetExtension:
//  *test.MyMessage does not implement proto.extendableProto (missing ExtensionMap method)

GetExtension succeeds with the original descriptor types (MessageOptions etc) if the extension defines a default type, but that provides pretty limited utility.

Metadata

Metadata

Assignees

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