[protobuf] protoreflect: fix list example code

54 views
Skip to first unread message

Michael Stapelberg (Gerrit)

unread,
Sep 20, 2022, 4:02:48 AM9/20/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Michael Stapelberg has uploaded this change for review.

View Change

protoreflect: fix list example code

Change-Id: I2c8afba104ae97be5e575226a47f6a7f20198abe
---
M reflect/protoreflect/value_union.go
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/reflect/protoreflect/value_union.go b/reflect/protoreflect/value_union.go
index ca8e28c..08e5ef7 100644
--- a/reflect/protoreflect/value_union.go
+++ b/reflect/protoreflect/value_union.go
@@ -54,11 +54,11 @@
// // Append a 0 to a "repeated int32" field.
// // Since the Value returned by Mutable is guaranteed to alias
// // the source message, modifying the Value modifies the message.
-// message.Mutable(fieldDesc).(List).Append(protoreflect.ValueOfInt32(0))
+// message.Mutable(fieldDesc).List().Append(protoreflect.ValueOfInt32(0))
//
// // Assign [0] to a "repeated int32" field by creating a new Value,
// // modifying it, and assigning it.
-// list := message.NewField(fieldDesc).(List)
+// list := message.NewField(fieldDesc).List()
// list.Append(protoreflect.ValueOfInt32(0))
// message.Set(fieldDesc, list)
// // ERROR: Since it is not defined whether Set aliases the source,

To view, visit change 431798. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: protobuf
Gerrit-Branch: master
Gerrit-Change-Id: I2c8afba104ae97be5e575226a47f6a7f20198abe
Gerrit-Change-Number: 431798
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Stapelberg <stape...@google.com>
Gerrit-MessageType: newchange

Nicolas Hillegeer (Gerrit)

unread,
Sep 20, 2022, 4:04:24 AM9/20/22
to Michael Stapelberg, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Attention is currently required from: Michael Stapelberg.

Patch set 1:Code-Review +2

View Change

    To view, visit change 431798. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: protobuf
    Gerrit-Branch: master
    Gerrit-Change-Id: I2c8afba104ae97be5e575226a47f6a7f20198abe
    Gerrit-Change-Number: 431798
    Gerrit-PatchSet: 1
    Gerrit-Owner: Michael Stapelberg <stape...@google.com>
    Gerrit-Reviewer: Nicolas Hillegeer <ak...@google.com>
    Gerrit-Attention: Michael Stapelberg <stape...@google.com>
    Gerrit-Comment-Date: Tue, 20 Sep 2022 08:04:18 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Michael Stapelberg (Gerrit)

    unread,
    Sep 20, 2022, 4:06:06 AM9/20/22
    to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Nicolas Hillegeer, golang-co...@googlegroups.com

    Michael Stapelberg submitted this change.

    View Change


    Approvals: Nicolas Hillegeer: Looks good to me, approved
    protoreflect: fix list example code

    Change-Id: I2c8afba104ae97be5e575226a47f6a7f20198abe
    Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/431798
    Reviewed-by: Nicolas Hillegeer <ak...@google.com>
    ---
    M reflect/protoreflect/value_union.go
    1 file changed, 13 insertions(+), 2 deletions(-)

    diff --git a/reflect/protoreflect/value_union.go b/reflect/protoreflect/value_union.go
    index ca8e28c..08e5ef7 100644
    --- a/reflect/protoreflect/value_union.go
    +++ b/reflect/protoreflect/value_union.go
    @@ -54,11 +54,11 @@
    // // Append a 0 to a "repeated int32" field.
    // // Since the Value returned by Mutable is guaranteed to alias
    // // the source message, modifying the Value modifies the message.
    -// message.Mutable(fieldDesc).(List).Append(protoreflect.ValueOfInt32(0))
    +// message.Mutable(fieldDesc).List().Append(protoreflect.ValueOfInt32(0))
    //
    // // Assign [0] to a "repeated int32" field by creating a new Value,
    // // modifying it, and assigning it.
    -// list := message.NewField(fieldDesc).(List)
    +// list := message.NewField(fieldDesc).List()
    // list.Append(protoreflect.ValueOfInt32(0))
    // message.Set(fieldDesc, list)
    // // ERROR: Since it is not defined whether Set aliases the source,

    To view, visit change 431798. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: protobuf
    Gerrit-Branch: master
    Gerrit-Change-Id: I2c8afba104ae97be5e575226a47f6a7f20198abe
    Gerrit-Change-Number: 431798
    Gerrit-PatchSet: 2
    Gerrit-Owner: Michael Stapelberg <stape...@google.com>
    Gerrit-Reviewer: Michael Stapelberg <stape...@google.com>
    Gerrit-Reviewer: Nicolas Hillegeer <ak...@google.com>
    Gerrit-MessageType: merged
    Reply all
    Reply to author
    Forward
    0 new messages