protocolbuffers / protocolbuffers/protocolbuffers.github.io

Encoding: Inconsistent example for packed repeated fields in Test4 message

未关闭
#282 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@jguamie 已经在做这个了。

开始于 2025年10月17日。

主要语言
HTML
星标
69
派生
179
PR 合并指标
30 天内没有已合并 PR

描述

In the documentation section about packed repeated fields, the following example is given:

message Test4 {
string d = 4;
repeated int32 e = 6;
}

The text says:

“… and we construct a Test4 message with d set to "hello", and e set to 1, 2, and 3, this could be encoded as 3206038e029ea705, or written out as Protoscope,

4: {"hello"}
6: {3 270 86942}”

Problem:
The encoding 3206038e029ea705 corresponds to e = [3, 270, 86942], not [1, 2, 3].

If e = [1, 2, 3], the correct encoding should be:

32 03 01 02 03

which expands to:

32 → field 6, wire type = length-delimited

03 → length = 3 bytes

01 02 03 → values [1, 2, 3]

The given encoding 3206038e029ea705 decodes as:

32 → field 6, wire type = length-delimited

06 → length = 6 bytes

03 → value = 3

8e 02 → value = 270

9e a7 05 → value = 86942

So the example text and the provided encoding are inconsistent.

Suggested fix:
Update the documentation so that either:

The example values match the provided encoding (e = [3, 270, 86942]), or

The encoded hex string is corrected to match the described values (e = [1, 2, 3]).

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。