Skip to content

Commit 17f4d51

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
Project import generated by Copybara.
PiperOrigin-RevId: 491985260 Change-Id: I835863f8a7ea806003a0906eef8bdc99d389d2cf
1 parent dd79665 commit 17f4d51

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

config.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# baseURL = 'https://protobuf.dev'
22
languageCode = 'en-us'
33
title = 'Protocol Buffers Documentation'
4-
theme = ["docsy"]
54
sidebar_search_disable = true
65

6+
# Theme
7+
[module]
8+
replacements = "github.com/FortAwesome/Font-Awesome -> ., github.com/twbs/bootstrap -> ."
9+
[[module.imports]]
10+
path = "docsy"
11+
712
# Language settings
813
contentDir = "content"
914
defaultContentLanguage = "en"

content/programming-guides/dos-donts.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,24 @@ Almost never change the default value of a proto field. This causes version skew
137137
between clients and servers. A client reading an unset value will see a
138138
different result than a server reading the same unset value when their builds
139139
straddle the proto change. Proto3 removed the ability to
140+
set default values.
141+
142+
## **Don't** Go from Repeated to Scalar
143+
144+
Although it won't cause crashes, you'll lose data. For JSON, a mismatch in
145+
repeatedness will lose the whole *message*. For numeric proto3 fields and proto2
146+
`packed` fields, going from repeated to scalar will lose all data in that
147+
*field*. For non-numeric proto3 fields and un-annotated proto2 fields, going
148+
from repeated to scalar will result in the last deserialized value "winning."
149+
150+
Going from scalar to repeated is OK in proto2 and in proto3 with
151+
`[packed=false]` because for binary serialization the scalar value becomes a
152+
one-element list .
153+
154+
## **Always** Create a Build Rule for Your Proto Files
155+
156+
If your proto is only used by a script that doesn't require a build rule, create
157+
a `proto_library` rule with an associated
140158
`build_test` rule.
141159

142160
With a `build_test` rule, errors in the file are caught when the test fails.

0 commit comments

Comments
 (0)