Example #1
0
func GetMap(file *descriptor.FileDescriptorProto, field *descriptor.FieldDescriptorProto) *descriptor.DescriptorProto {
	if !field.IsMessage() {
		return nil
	}
	typeName := field.GetTypeName()
	if strings.Contains(typeName, "Map") && !strings.HasSuffix(typeName, "Entry") {
		typeName += "." + CamelCase(field.GetName()) + "Entry"
	}
	ts := strings.Split(typeName, ".")
	if len(ts) == 1 {
		return file.GetMessage(typeName)
	}
	newTypeName := strings.Join(ts[2:], ".")
	return file.GetMessage(newTypeName)
}
Example #2
0
func NotInPackageGoogleProtobuf(file *descriptor.FileDescriptorProto) bool {
	return !strings.HasPrefix(file.GetPackage(), "google.protobuf")
}
Example #3
0
func IsProto3(file *google_protobuf.FileDescriptorProto) bool {
	return file.GetSyntax() == "proto3"
}