"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "vendor/google.golang.org/protobuf/encoding/prototext/encode.go" between
k6-0.45.0.tar.gz and k6-0.45.1.tar.gz

About: k6 is a load and performance testing tool that provides a clean, approachable scripting API, local and cloud execution, and flexible configuration.

encode.go  (k6-0.45.0):encode.go  (k6-0.45.1)
skipping to change at line 104 skipping to change at line 104
o.AllowPartial = true o.AllowPartial = true
o.EmitUnknown = true o.EmitUnknown = true
b, _ := o.Marshal(m) b, _ := o.Marshal(m)
return string(b) return string(b)
} }
// Marshal writes the given proto.Message in textproto format using options in // Marshal writes the given proto.Message in textproto format using options in
// MarshalOptions object. Do not depend on the output being stable. It may // MarshalOptions object. Do not depend on the output being stable. It may
// change over time across different versions of the program. // change over time across different versions of the program.
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) { func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
return o.marshal(m) return o.marshal(nil, m)
}
// MarshalAppend appends the textproto format encoding of m to b,
// returning the result.
func (o MarshalOptions) MarshalAppend(b []byte, m proto.Message) ([]byte, error)
{
return o.marshal(b, m)
} }
// marshal is a centralized function that all marshal operations go through. // marshal is a centralized function that all marshal operations go through.
// For profiling purposes, avoid changing the name of this function or // For profiling purposes, avoid changing the name of this function or
// introducing other code paths for marshal that do not go through this. // introducing other code paths for marshal that do not go through this.
func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) { func (o MarshalOptions) marshal(b []byte, m proto.Message) ([]byte, error) {
var delims = [2]byte{'{', '}'} var delims = [2]byte{'{', '}'}
if o.Multiline && o.Indent == "" { if o.Multiline && o.Indent == "" {
o.Indent = defaultIndent o.Indent = defaultIndent
} }
if o.Resolver == nil { if o.Resolver == nil {
o.Resolver = protoregistry.GlobalTypes o.Resolver = protoregistry.GlobalTypes
} }
internalEnc, err := text.NewEncoder(o.Indent, delims, o.EmitASCII) internalEnc, err := text.NewEncoder(b, o.Indent, delims, o.EmitASCII)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Treat nil message interface as an empty message, // Treat nil message interface as an empty message,
// in which case there is nothing to output. // in which case there is nothing to output.
if m == nil { if m == nil {
return []byte{}, nil return b, nil
} }
enc := encoder{internalEnc, o} enc := encoder{internalEnc, o}
err = enc.marshalMessage(m.ProtoReflect(), false) err = enc.marshalMessage(m.ProtoReflect(), false)
if err != nil { if err != nil {
return nil, err return nil, err
} }
out := enc.Bytes() out := enc.Bytes()
if len(o.Indent) > 0 && len(out) > 0 { if len(o.Indent) > 0 && len(out) > 0 {
out = append(out, '\n') out = append(out, '\n')
 End of changes. 4 change blocks. 
4 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)