1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
|
package descriptor
import (
"fmt"
"strings"
"github.com/grpc-ecosystem/grpc-gateway/v2/internal/casing"
"github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/pluginpb"
)
// IsWellKnownType returns true if the provided fully qualified type name is considered 'well-known'.
func IsWellKnownType(typeName string) bool {
_, ok := wellKnownTypeConv[typeName]
return ok
}
// GoPackage represents a golang package.
type GoPackage struct {
// Path is the package path to the package.
Path string
// Name is the package name of the package
Name string
// Alias is an alias of the package unique within the current invocation of gRPC-Gateway generator.
Alias string
}
// Standard returns whether the import is a golang standard package.
func (p GoPackage) Standard() bool {
return !strings.Contains(p.Path, ".")
}
// String returns a string representation of this package in the form of import line in golang.
func (p GoPackage) String() string {
if p.Alias == "" {
return fmt.Sprintf("%q", p.Path)
}
return fmt.Sprintf("%s %q", p.Alias, p.Path)
}
// ResponseFile wraps pluginpb.CodeGeneratorResponse_File.
type ResponseFile struct {
*pluginpb.CodeGeneratorResponse_File
// GoPkg is the Go package of the generated file.
GoPkg GoPackage
}
// File wraps descriptorpb.FileDescriptorProto for richer features.
type File struct {
*descriptorpb.FileDescriptorProto
// GoPkg is the go package of the go file generated from this file.
GoPkg GoPackage
// GeneratedFilenamePrefix is used to construct filenames for generated
// files associated with this source file.
//
// For example, the source file "dir/foo.proto" might have a filename prefix
// of "dir/foo". Appending ".pb.go" produces an output file of "dir/foo.pb.go".
GeneratedFilenamePrefix string
// Messages is the list of messages defined in this file.
Messages []*Message
// Enums is the list of enums defined in this file.
Enums []*Enum
// Services is the list of services defined in this file.
Services []*Service
}
// Pkg returns package name or alias if it's present
func (f *File) Pkg() string {
pkg := f.GoPkg.Name
if alias := f.GoPkg.Alias; alias != "" {
pkg = alias
}
return pkg
}
// proto2 determines if the syntax of the file is proto2.
func (f *File) proto2() bool {
return f.Syntax == nil || f.GetSyntax() == "proto2"
}
// Message describes a protocol buffer message types.
type Message struct {
*descriptorpb.DescriptorProto
// File is the file where the message is defined.
File *File
// Outers is a list of outer messages if this message is a nested type.
Outers []string
// Fields is a list of message fields.
Fields []*Field
// Index is proto path index of this message in File.
Index int
// ForcePrefixedName when set to true, prefixes a type with a package prefix.
ForcePrefixedName bool
}
// FQMN returns a fully qualified message name of this message.
func (m *Message) FQMN() string {
components := []string{""}
if m.File.Package != nil {
components = append(components, m.File.GetPackage())
}
components = append(components, m.Outers...)
components = append(components, m.GetName())
return strings.Join(components, ".")
}
// GoType returns a go type name for the message type.
// It prefixes the type name with the package alias if
// its belonging package is not "currentPackage".
func (m *Message) GoType(currentPackage string) string {
var components []string
components = append(components, m.Outers...)
components = append(components, m.GetName())
name := strings.Join(components, "_")
if !m.ForcePrefixedName && m.File.GoPkg.Path == currentPackage {
return name
}
return fmt.Sprintf("%s.%s", m.File.Pkg(), name)
}
// Enum describes a protocol buffer enum types.
type Enum struct {
*descriptorpb.EnumDescriptorProto
// File is the file where the enum is defined
File *File
// Outers is a list of outer messages if this enum is a nested type.
Outers []string
// Index is a enum index value.
Index int
// ForcePrefixedName when set to true, prefixes a type with a package prefix.
ForcePrefixedName bool
}
// FQEN returns a fully qualified enum name of this enum.
func (e *Enum) FQEN() string {
components := []string{""}
if e.File.Package != nil {
components = append(components, e.File.GetPackage())
}
components = append(components, e.Outers...)
components = append(components, e.GetName())
return strings.Join(components, ".")
}
// GoType returns a go type name for the enum type.
// It prefixes the type name with the package alias if
// its belonging package is not "currentPackage".
func (e *Enum) GoType(currentPackage string) string {
var components []string
components = append(components, e.Outers...)
components = append(components, e.GetName())
name := strings.Join(components, "_")
if !e.ForcePrefixedName && e.File.GoPkg.Path == currentPackage {
return name
}
return fmt.Sprintf("%s.%s", e.File.Pkg(), name)
}
// Service wraps descriptorpb.ServiceDescriptorProto for richer features.
type Service struct {
*descriptorpb.ServiceDescriptorProto
// File is the file where this service is defined.
File *File
// Methods is the list of methods defined in this service.
Methods []*Method
// ForcePrefixedName when set to true, prefixes a type with a package prefix.
ForcePrefixedName bool
}
// FQSN returns the fully qualified service name of this service.
func (s *Service) FQSN() string {
components := []string{""}
if s.File.Package != nil {
components = append(components, s.File.GetPackage())
}
components = append(components, s.GetName())
return strings.Join(components, ".")
}
// InstanceName returns object name of the service with package prefix if needed
func (s *Service) InstanceName() string {
if !s.ForcePrefixedName {
return s.GetName()
}
return fmt.Sprintf("%s.%s", s.File.Pkg(), s.GetName())
}
// ClientConstructorName returns name of the Client constructor with package prefix if needed
func (s *Service) ClientConstructorName() string {
constructor := "New" + s.GetName() + "Client"
if !s.ForcePrefixedName {
return constructor
}
return fmt.Sprintf("%s.%s", s.File.Pkg(), constructor)
}
// Method wraps descriptorpb.MethodDescriptorProto for richer features.
type Method struct {
*descriptorpb.MethodDescriptorProto
// Service is the service which this method belongs to.
Service *Service
// RequestType is the message type of requests to this method.
RequestType *Message
// ResponseType is the message type of responses from this method.
ResponseType *Message
Bindings []*Binding
}
// FQMN returns a fully qualified rpc method name of this method.
func (m *Method) FQMN() string {
var components []string
components = append(components, m.Service.FQSN())
components = append(components, m.GetName())
return strings.Join(components, ".")
}
// Binding describes how an HTTP endpoint is bound to a gRPC method.
type Binding struct {
// Method is the method which the endpoint is bound to.
Method *Method
// Index is a zero-origin index of the binding in the target method
Index int
// PathTmpl is path template where this method is mapped to.
PathTmpl httprule.Template
// HTTPMethod is the HTTP method which this method is mapped to.
HTTPMethod string
// PathParams is the list of parameters provided in HTTP request paths.
PathParams []Parameter
// Body describes parameters provided in HTTP request body.
Body *Body
// ResponseBody describes field in response struct to marshal in HTTP response body.
ResponseBody *Body
}
// ExplicitParams returns a list of explicitly bound parameters of "b",
// i.e. a union of field path for body and field paths for path parameters.
func (b *Binding) ExplicitParams() []string {
var result []string
if b.Body != nil {
result = append(result, b.Body.FieldPath.String())
}
for _, p := range b.PathParams {
result = append(result, p.FieldPath.String())
}
return result
}
// Field wraps descriptorpb.FieldDescriptorProto for richer features.
type Field struct {
*descriptorpb.FieldDescriptorProto
// Message is the message type which this field belongs to.
Message *Message
// FieldMessage is the message type of the field.
FieldMessage *Message
// ForcePrefixedName when set to true, prefixes a type with a package prefix.
ForcePrefixedName bool
}
// FQFN returns a fully qualified field name of this field.
func (f *Field) FQFN() string {
return strings.Join([]string{f.Message.FQMN(), f.GetName()}, ".")
}
// Parameter is a parameter provided in http requests
type Parameter struct {
// FieldPath is a path to a proto field which this parameter is mapped to.
FieldPath
// Target is the proto field which this parameter is mapped to.
Target *Field
// Method is the method which this parameter is used for.
Method *Method
}
// ConvertFuncExpr returns a go expression of a converter function.
// The converter function converts a string into a value for the parameter.
func (p Parameter) ConvertFuncExpr() (string, error) {
tbl := proto3ConvertFuncs
if !p.IsProto2() && p.IsRepeated() {
tbl = proto3RepeatedConvertFuncs
} else if !p.IsProto2() && p.IsOptionalProto3() {
tbl = proto3OptionalConvertFuncs
} else if p.IsProto2() && !p.IsRepeated() {
tbl = proto2ConvertFuncs
} else if p.IsProto2() && p.IsRepeated() {
tbl = proto2RepeatedConvertFuncs
}
typ := p.Target.GetType()
conv, ok := tbl[typ]
if !ok {
conv, ok = wellKnownTypeConv[p.Target.GetTypeName()]
}
if !ok {
return "", fmt.Errorf("unsupported field type %s of parameter %s in %s.%s", typ, p.FieldPath, p.Method.Service.GetName(), p.Method.GetName())
}
return conv, nil
}
// IsEnum returns true if the field is an enum type, otherwise false is returned.
func (p Parameter) IsEnum() bool {
return p.Target.GetType() == descriptorpb.FieldDescriptorProto_TYPE_ENUM
}
// IsRepeated returns true if the field is repeated, otherwise false is returned.
func (p Parameter) IsRepeated() bool {
return p.Target.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED
}
// IsProto2 returns true if the field is proto2, otherwise false is returned.
func (p Parameter) IsProto2() bool {
return p.Target.Message.File.proto2()
}
// Body describes a http (request|response) body to be sent to the (method|client).
// This is used in body and response_body options in google.api.HttpRule
type Body struct {
// FieldPath is a path to a proto field which the (request|response) body is mapped to.
// The (request|response) body is mapped to the (request|response) type itself if FieldPath is empty.
FieldPath FieldPath
}
// AssignableExpr returns an assignable expression in Go to be used to initialize method request object.
// It starts with "msgExpr", which is the go expression of the method request object.
func (b Body) AssignableExpr(msgExpr string, currentPackage string) string {
return b.FieldPath.AssignableExpr(msgExpr, currentPackage)
}
// AssignableExprPrep returns preparatory statements for an assignable expression to initialize the
// method request object.
func (b Body) AssignableExprPrep(msgExpr string, currentPackage string) string {
return b.FieldPath.AssignableExprPrep(msgExpr, currentPackage)
}
// FieldPath is a path to a field from a request message.
type FieldPath []FieldPathComponent
// String returns a string representation of the field path.
func (p FieldPath) String() string {
components := make([]string, 0, len(p))
for _, c := range p {
components = append(components, c.Name)
}
return strings.Join(components, ".")
}
// IsNestedProto3 indicates whether the FieldPath is a nested Proto3 path.
func (p FieldPath) IsNestedProto3() bool {
if len(p) > 1 && !p[0].Target.Message.File.proto2() {
return true
}
return false
}
// IsOptionalProto3 indicates whether the FieldPath is a proto3 optional field.
func (p FieldPath) IsOptionalProto3() bool {
if len(p) == 0 {
return false
}
return p[0].Target.GetProto3Optional()
}
// AssignableExpr is an assignable expression in Go to be used to assign a value to the target field.
// It starts with "msgExpr", which is the go expression of the method request object. Before using
// such an expression the prep statements must be emitted first, in case the field path includes
// a oneof. See FieldPath.AssignableExprPrep.
func (p FieldPath) AssignableExpr(msgExpr string, currentPackage string) string {
l := len(p)
if l == 0 {
return msgExpr
}
components := msgExpr
for i, c := range p {
// We need to check if the target is not proto3_optional first.
// Under the hood, proto3_optional uses oneof to signal to old proto3 clients
// that presence is tracked for this field. This oneof is known as a "synthetic" oneof.
if !c.Target.GetProto3Optional() && c.Target.OneofIndex != nil {
index := c.Target.OneofIndex
msg := c.Target.Message
oneOfName := casing.Camel(msg.GetOneofDecl()[*index].GetName())
oneofFieldName := msg.GoType(currentPackage) + "_" + c.AssignableExpr()
if c.Target.ForcePrefixedName {
oneofFieldName = msg.File.Pkg() + "." + msg.GetName() + "_" + c.AssignableExpr()
}
components = components + "." + oneOfName + ".(*" + oneofFieldName + ")"
}
if i == l-1 {
components = components + "." + c.AssignableExpr()
continue
}
components = components + "." + c.ValueExpr()
}
return components
}
// AssignableExprPrep returns preparation statements for an assignable expression to assign a value
// to the target field. The Go expression of the method request object is "msgExpr". This is only
// needed for field paths that contain oneofs. Otherwise, an empty string is returned.
func (p FieldPath) AssignableExprPrep(msgExpr string, currentPackage string) string {
l := len(p)
if l == 0 {
return ""
}
var preparations []string
components := msgExpr
for i, c := range p {
// We need to check if the target is not proto3_optional first.
// Under the hood, proto3_optional uses oneof to signal to old proto3 clients
// that presence is tracked for this field. This oneof is known as a "synthetic" oneof.
if !c.Target.GetProto3Optional() && c.Target.OneofIndex != nil {
index := c.Target.OneofIndex
msg := c.Target.Message
oneOfName := casing.Camel(msg.GetOneofDecl()[*index].GetName())
oneofFieldName := msg.GoType(currentPackage) + "_" + c.AssignableExpr()
if c.Target.ForcePrefixedName {
oneofFieldName = msg.File.Pkg() + "." + msg.GetName() + "_" + c.AssignableExpr()
}
components = components + "." + oneOfName
s := `if %s == nil {
%s =&%s{}
} else if _, ok := %s.(*%s); !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "expect type: *%s, but: %%t\n",%s)
}`
preparations = append(preparations, fmt.Sprintf(s, components, components, oneofFieldName, components, oneofFieldName, oneofFieldName, components))
components = components + ".(*" + oneofFieldName + ")"
}
if i == l-1 {
components = components + "." + c.AssignableExpr()
continue
}
components = components + "." + c.ValueExpr()
}
return strings.Join(preparations, "\n")
}
// FieldPathComponent is a path component in FieldPath
type FieldPathComponent struct {
// Name is a name of the proto field which this component corresponds to.
// TODO(yugui) is this necessary?
Name string
// Target is the proto field which this component corresponds to.
Target *Field
}
// AssignableExpr returns an assignable expression in go for this field.
func (c FieldPathComponent) AssignableExpr() string {
return casing.Camel(c.Name)
}
// ValueExpr returns an expression in go for this field.
func (c FieldPathComponent) ValueExpr() string {
if c.Target.Message.File.proto2() {
return fmt.Sprintf("Get%s()", casing.Camel(c.Name))
}
return casing.Camel(c.Name)
}
var (
proto3ConvertFuncs = map[descriptorpb.FieldDescriptorProto_Type]string{
descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: "runtime.Float64",
descriptorpb.FieldDescriptorProto_TYPE_FLOAT: "runtime.Float32",
descriptorpb.FieldDescriptorProto_TYPE_INT64: "runtime.Int64",
descriptorpb.FieldDescriptorProto_TYPE_UINT64: "runtime.Uint64",
descriptorpb.FieldDescriptorProto_TYPE_INT32: "runtime.Int32",
descriptorpb.FieldDescriptorProto_TYPE_FIXED64: "runtime.Uint64",
descriptorpb.FieldDescriptorProto_TYPE_FIXED32: "runtime.Uint32",
descriptorpb.FieldDescriptorProto_TYPE_BOOL: "runtime.Bool",
descriptorpb.FieldDescriptorProto_TYPE_STRING: "runtime.String",
// FieldDescriptorProto_TYPE_GROUP
// FieldDescriptorProto_TYPE_MESSAGE
descriptorpb.FieldDescriptorProto_TYPE_BYTES: "runtime.Bytes",
descriptorpb.FieldDescriptorProto_TYPE_UINT32: "runtime.Uint32",
descriptorpb.FieldDescriptorProto_TYPE_ENUM: "runtime.Enum",
descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: "runtime.Int32",
descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: "runtime.Int64",
descriptorpb.FieldDescriptorProto_TYPE_SINT32: "runtime.Int32",
descriptorpb.FieldDescriptorProto_TYPE_SINT64: "runtime.Int64",
}
proto3OptionalConvertFuncs = func() map[descriptorpb.FieldDescriptorProto_Type]string {
result := make(map[descriptorpb.FieldDescriptorProto_Type]string)
for typ, converter := range proto3ConvertFuncs {
// TODO: this will use convert functions from proto2.
// The converters returning pointers should be moved
// to a more generic file.
result[typ] = converter + "P"
}
return result
}()
// TODO: replace it with a IIFE
proto3RepeatedConvertFuncs = map[descriptorpb.FieldDescriptorProto_Type]string{
descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: "runtime.Float64Slice",
descriptorpb.FieldDescriptorProto_TYPE_FLOAT: "runtime.Float32Slice",
descriptorpb.FieldDescriptorProto_TYPE_INT64: "runtime.Int64Slice",
descriptorpb.FieldDescriptorProto_TYPE_UINT64: "runtime.Uint64Slice",
descriptorpb.FieldDescriptorProto_TYPE_INT32: "runtime.Int32Slice",
descriptorpb.FieldDescriptorProto_TYPE_FIXED64: "runtime.Uint64Slice",
descriptorpb.FieldDescriptorProto_TYPE_FIXED32: "runtime.Uint32Slice",
descriptorpb.FieldDescriptorProto_TYPE_BOOL: "runtime.BoolSlice",
descriptorpb.FieldDescriptorProto_TYPE_STRING: "runtime.StringSlice",
// FieldDescriptorProto_TYPE_GROUP
// FieldDescriptorProto_TYPE_MESSAGE
descriptorpb.FieldDescriptorProto_TYPE_BYTES: "runtime.BytesSlice",
descriptorpb.FieldDescriptorProto_TYPE_UINT32: "runtime.Uint32Slice",
descriptorpb.FieldDescriptorProto_TYPE_ENUM: "runtime.EnumSlice",
descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: "runtime.Int32Slice",
descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: "runtime.Int64Slice",
descriptorpb.FieldDescriptorProto_TYPE_SINT32: "runtime.Int32Slice",
descriptorpb.FieldDescriptorProto_TYPE_SINT64: "runtime.Int64Slice",
}
proto2ConvertFuncs = map[descriptorpb.FieldDescriptorProto_Type]string{
descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: "runtime.Float64P",
descriptorpb.FieldDescriptorProto_TYPE_FLOAT: "runtime.Float32P",
descriptorpb.FieldDescriptorProto_TYPE_INT64: "runtime.Int64P",
descriptorpb.FieldDescriptorProto_TYPE_UINT64: "runtime.Uint64P",
descriptorpb.FieldDescriptorProto_TYPE_INT32: "runtime.Int32P",
descriptorpb.FieldDescriptorProto_TYPE_FIXED64: "runtime.Uint64P",
descriptorpb.FieldDescriptorProto_TYPE_FIXED32: "runtime.Uint32P",
descriptorpb.FieldDescriptorProto_TYPE_BOOL: "runtime.BoolP",
descriptorpb.FieldDescriptorProto_TYPE_STRING: "runtime.StringP",
// FieldDescriptorProto_TYPE_GROUP
// FieldDescriptorProto_TYPE_MESSAGE
// FieldDescriptorProto_TYPE_BYTES
// TODO(yugui) Handle bytes
descriptorpb.FieldDescriptorProto_TYPE_UINT32: "runtime.Uint32P",
descriptorpb.FieldDescriptorProto_TYPE_ENUM: "runtime.EnumP",
descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: "runtime.Int32P",
descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: "runtime.Int64P",
descriptorpb.FieldDescriptorProto_TYPE_SINT32: "runtime.Int32P",
descriptorpb.FieldDescriptorProto_TYPE_SINT64: "runtime.Int64P",
}
proto2RepeatedConvertFuncs = map[descriptorpb.FieldDescriptorProto_Type]string{
descriptorpb.FieldDescriptorProto_TYPE_DOUBLE: "runtime.Float64Slice",
descriptorpb.FieldDescriptorProto_TYPE_FLOAT: "runtime.Float32Slice",
descriptorpb.FieldDescriptorProto_TYPE_INT64: "runtime.Int64Slice",
descriptorpb.FieldDescriptorProto_TYPE_UINT64: "runtime.Uint64Slice",
descriptorpb.FieldDescriptorProto_TYPE_INT32: "runtime.Int32Slice",
descriptorpb.FieldDescriptorProto_TYPE_FIXED64: "runtime.Uint64Slice",
descriptorpb.FieldDescriptorProto_TYPE_FIXED32: "runtime.Uint32Slice",
descriptorpb.FieldDescriptorProto_TYPE_BOOL: "runtime.BoolSlice",
descriptorpb.FieldDescriptorProto_TYPE_STRING: "runtime.StringSlice",
// FieldDescriptorProto_TYPE_GROUP
// FieldDescriptorProto_TYPE_MESSAGE
// FieldDescriptorProto_TYPE_BYTES
// TODO(maros7) Handle bytes
descriptorpb.FieldDescriptorProto_TYPE_UINT32: "runtime.Uint32Slice",
descriptorpb.FieldDescriptorProto_TYPE_ENUM: "runtime.EnumSlice",
descriptorpb.FieldDescriptorProto_TYPE_SFIXED32: "runtime.Int32Slice",
descriptorpb.FieldDescriptorProto_TYPE_SFIXED64: "runtime.Int64Slice",
descriptorpb.FieldDescriptorProto_TYPE_SINT32: "runtime.Int32Slice",
descriptorpb.FieldDescriptorProto_TYPE_SINT64: "runtime.Int64Slice",
}
wellKnownTypeConv = map[string]string{
".google.protobuf.Timestamp": "runtime.Timestamp",
".google.protobuf.Duration": "runtime.Duration",
".google.protobuf.StringValue": "runtime.StringValue",
".google.protobuf.FloatValue": "runtime.FloatValue",
".google.protobuf.DoubleValue": "runtime.DoubleValue",
".google.protobuf.BoolValue": "runtime.BoolValue",
".google.protobuf.BytesValue": "runtime.BytesValue",
".google.protobuf.Int32Value": "runtime.Int32Value",
".google.protobuf.UInt32Value": "runtime.UInt32Value",
".google.protobuf.Int64Value": "runtime.Int64Value",
".google.protobuf.UInt64Value": "runtime.UInt64Value",
}
)
|