Skip to content

Commit

Permalink
field_presence.md: fix Go example (#8788)
Browse files Browse the repository at this point in the history
Go generated code does not have Has methods.

Remove extraneous parentheses and semicolons.
  • Loading branch information
neild committed Jul 8, 2021
1 parent d2c82df commit 3588a77
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/field_presence.md
Expand Up @@ -313,25 +313,25 @@ No presence:

```
m := GetProto()
if (m.GetFoo() != 0) {
if m.Foo != 0 {
// "Clear" the field:
m.Foo = 0;
m.Foo = 0
} else {
// Default value: field may not have been present.
m.Foo = 1;
m.Foo = 1
}
```

Explicit presence:

```
m := GetProto()
if (m.HasFoo()) {
if m.Foo != nil {
// Clear the field:
m.Foo = nil
} else {
// Field is not present, so set it.
m.Foo = proto.Int32(1);
m.Foo = proto.Int32(1)
}
```

Expand Down

0 comments on commit 3588a77

Please sign in to comment.