Пример #1
0
func GetMap(file *descriptor.FileDescriptorProto, field *descriptor.FieldDescriptorProto) *descriptor.DescriptorProto {
	if !field.IsMessage() {
		return nil
	}
	typeName := strings.TrimPrefix(field.GetTypeName(), "."+file.GetPackage()+".")
	if strings.Contains(typeName, "Map") && !strings.HasSuffix(typeName, "Entry") {
		typeName += "." + CamelCase(field.GetName()) + "Entry"
	}
	return file.GetMessage(typeName)
}
Пример #2
0
func NotGoogleProtobufDescriptorProto(file *descriptor.FileDescriptorProto) bool {
	// can not just check if file.GetName() == "google/protobuf/descriptor.proto" because we do not want to assume compile path
	_, fileName := filepath.Split(file.GetName())
	return !(file.GetPackage() == "google.protobuf" && fileName == "descriptor.proto")
}
Пример #3
0
func NotInPackageGoogleProtobuf(file *descriptor.FileDescriptorProto) bool {
	return !strings.HasPrefix(file.GetPackage(), "google.protobuf")
}