Skip to content

Commit 8068a68

Browse files
committed
reproduce comments
1 parent da1b38b commit 8068a68

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

utils/protojson/protojson.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
15
package protojson
26

37
import (
@@ -8,19 +12,30 @@ import (
812
type MarshalOptions = protojson.MarshalOptions
913
type UnmarshalOptions = protojson.UnmarshalOptions
1014

15+
// Format formats the message as a multiline string.
16+
// This function is only intended for human consumption and ignores errors.
17+
// Do not depend on the output being stable. Its output will change across
18+
// different builds of your program, even when using the same version of the
19+
// protobuf module.
1120
func Format(m proto.Message) string {
1221
return MarshalOptions{
1322
Multiline: true,
1423
AllowPartial: true,
1524
}.Format(m)
1625
}
1726

27+
// Marshal writes the given [proto.Message] in JSON format using default options.
28+
// Do not depend on the output being stable. Its output will change across
29+
// different builds of your program, even when using the same version of the
30+
// protobuf module.
1831
func Marshal(m proto.Message) ([]byte, error) {
1932
return MarshalOptions{
2033
AllowPartial: true,
2134
}.Marshal(m)
2235
}
2336

37+
// Unmarshal reads the given []byte into the given [proto.Message].
38+
// The provided message must be mutable (e.g., a non-nil pointer to a message).
2439
func Unmarshal(b []byte, m proto.Message) error {
2540
return UnmarshalOptions{
2641
AllowPartial: true,

0 commit comments

Comments
 (0)