Source File
buffer.go
Belonging Package
github.com/golang/protobuf/proto
package proto
import (
)
const (
WireVarint = 0
WireFixed32 = 5
WireFixed64 = 1
WireBytes = 2
WireStartGroup = 3
WireEndGroup = 4
)
func ( uint64) []byte {
return protowire.AppendVarint(nil, )
}
func ( uint64) int {
return protowire.SizeVarint()
}
func ( []byte) (uint64, int) {
, := protowire.ConsumeVarint()
if < 0 {
return 0, 0
}
return ,
}
func ( *Buffer) ( bool) {
.deterministic =
}
func ( *Buffer) ( Message) error {
var error
.buf, = marshalAppend(.buf, , .deterministic)
return
}
func ( *Buffer) ( Message) error {
:= UnmarshalMerge(.Unread(), )
.idx = len(.buf)
return
}
type unknownFields struct{ XXX_unrecognized protoimpl.UnknownFields }
func ( *unknownFields) () string { panic("not implemented") }
func ( *unknownFields) () { panic("not implemented") }
func ( *unknownFields) () { panic("not implemented") }
func (*Buffer) ( string, []byte) {
:= MessageReflect(new(unknownFields))
.SetUnknown()
, _ = prototext.MarshalOptions{AllowPartial: true, Indent: "\t"}.Marshal(.Interface())
fmt.Printf("==== %s ====\n%s==== %s ====\n", , , )
}
func ( *Buffer) ( Message) error {
var error
.buf = protowire.AppendVarint(.buf, uint64(Size()))
.buf, = marshalAppend(.buf, , .deterministic)
return
}
func ( *Buffer) ( Message) error {
, := .DecodeRawBytes(false)
if != nil {
return
}
return UnmarshalMerge(, )
}
func ( *Buffer) ( Message) error {
, , := consumeGroup(.buf[.idx:])
if != nil {
return
}
.idx +=
return UnmarshalMerge(, )
}
func ( []byte) ([]byte, int, error) {
:=
:= 1 // assume this follows a start group marker
for {
, , := protowire.ConsumeTag()
if < 0 {
return nil, 0, protowire.ParseError()
}
= [:]
var int
switch {
case protowire.VarintType:
_, = protowire.ConsumeVarint()
case protowire.Fixed32Type:
_, = protowire.ConsumeFixed32()
case protowire.Fixed64Type:
_, = protowire.ConsumeFixed64()
case protowire.BytesType:
_, = protowire.ConsumeBytes()
case protowire.StartGroupType:
++
case protowire.EndGroupType:
--
default:
return nil, 0, errors.New("proto: cannot parse reserved wire type")
}
if < 0 {
return nil, 0, protowire.ParseError()
}
= [:]
if == 0 {
return [:len()-len()-], len() - len(), nil
}
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |