MCPcopy
hub / github.com/golang/protobuf / writeUnknownFields

Method writeUnknownFields

proto/text_encode.go:432–493  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

430}
431
432func (w *textWriter) writeUnknownFields(b []byte) {
433 if !w.compact {
434 fmt.Fprintf(w, "/* %d unknown bytes */\n", len(b))
435 }
436
437 for len(b) > 0 {
438 num, wtyp, n := protowire.ConsumeTag(b)
439 if n < 0 {
440 return
441 }
442 b = b[n:]
443
444 if wtyp == protowire.EndGroupType {
445 w.indent--
446 w.Write(endBraceNewline)
447 continue
448 }
449 fmt.Fprint(w, num)
450 if wtyp != protowire.StartGroupType {
451 w.WriteByte(':')
452 }
453 if !w.compact || wtyp == protowire.StartGroupType {
454 w.WriteByte(' ')
455 }
456 switch wtyp {
457 case protowire.VarintType:
458 v, n := protowire.ConsumeVarint(b)
459 if n < 0 {
460 return
461 }
462 b = b[n:]
463 fmt.Fprint(w, v)
464 case protowire.Fixed32Type:
465 v, n := protowire.ConsumeFixed32(b)
466 if n < 0 {
467 return
468 }
469 b = b[n:]
470 fmt.Fprint(w, v)
471 case protowire.Fixed64Type:
472 v, n := protowire.ConsumeFixed64(b)
473 if n < 0 {
474 return
475 }
476 b = b[n:]
477 fmt.Fprint(w, v)
478 case protowire.BytesType:
479 v, n := protowire.ConsumeBytes(b)
480 if n < 0 {
481 return
482 }
483 b = b[n:]
484 fmt.Fprintf(w, "%q", v)
485 case protowire.StartGroupType:
486 w.WriteByte('{')
487 w.indent++
488 default:
489 fmt.Fprintf(w, "/* unknown wire type %d */", wtyp)

Callers 1

writeMessageMethod · 0.95

Calls 2

WriteMethod · 0.95
WriteByteMethod · 0.95

Tested by

no test coverage detected