liveBook · Manning

Field identifier

As explained in Learn Go with Pocket-Sized Projects

A field identifier is the unique numeric tag assigned to a Protobuf message field for serialized-data recognition and compatibility.

A field identifier is the unique numeric tag assigned to a field in a Protobuf message. Consumers use it to recognize serialized fields across API versions. section 10.1.1

When defining Protobuf fields:

  • Assign every field a unique numeric identifier. section 10.1.1
  • Keep an identifier permanently associated with its field; renumbering can break backward compatibility. section 10.1.1
  • Use incremental numbering when practical, without leaving gaps. section 10.1.1
Listing 10.3 habit.proto: Defining the Habit message
// Habit represents an objective one wants to complete 
// a given number of times per week.
message Habit { #1
    // Name of the habit, cannot be empty
    string name = 1; #2
    // Frequency, expressed in times per week. 
    int32 weekly_frequency = 2;
}

A compact Habit message assigns name the identifier 1 and weekly_frequency the identifier 2. section 10.1.1

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Explains numeric tags, uniqueness, permanent assignment, and incremental numbering without detailing serialization internals.
Examples
Uses a Habit message where name equals 1 and weekly_frequency equals 2.
What you can do after
Build Protobuf message schemas with stable, uniquely numbered fields.
How it connects
Connects Protobuf messages with serialization, backward compatibility, and generated Go code.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.