MCPcopy
hub / github.com/gogo/protobuf / RegisterType

Function RegisterType

proto/properties.go:545–560  ·  view source on GitHub ↗

RegisterType is called from generated code and maps from the fully qualified proto name to the type (pointer to struct) of the protocol buffer.

(x Message, name string)

Source from the content-addressed store, hash-verified

543// RegisterType is called from generated code and maps from the fully qualified
544// proto name to the type (pointer to struct) of the protocol buffer.
545func RegisterType(x Message, name string) {
546 if _, ok := protoTypedNils[name]; ok {
547 // TODO: Some day, make this a panic.
548 log.Printf("proto: duplicate proto type registered: %s", name)
549 return
550 }
551 t := reflect.TypeOf(x)
552 if v := reflect.ValueOf(x); v.Kind() == reflect.Ptr && v.Pointer() == 0 {
553 // Generated code always calls RegisterType with nil x.
554 // This check is just for extra safety.
555 protoTypedNils[name] = x
556 } else {
557 protoTypedNils[name] = reflect.Zero(t).Interface().(Message)
558 }
559 revProtoTypes[t] = name
560}
561
562// RegisterMapType is called from generated code and maps from the fully qualified
563// proto name to the native map type of the proto map definition.

Callers 15

initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92
initFunction · 0.92

Calls

no outgoing calls

Tested by 1

initFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…