Forbidden types

This rule enforces that fields do not use unsigned integer types (because many programming languages and systems do not support them well), as mandated in AIP-141.

Details

This rule scans all fields and complains if it sees any of the following types:

  • fixed32
  • fixed64
  • uint32
  • uint64

It suggests use of int32 or int64 instead.

Examples

Incorrect code for this rule:

// Incorrect.
message Book {
  string name = 1;
  uint32 page_count = 2;  // Should be `int32`.
}

Correct code for this rule:

// Correct.
message Book {
  string name = 1;
  int32 page_count = 2;
}

Disabling

If you need to violate this rule, use a leading comment above the method. Remember to also include an aip.dev/not-precedent comment explaining why.

// (-- api-linter: core::0141::forbidden-types=disabled
//     aip.dev/not-precedent: We need to do this because reasons. --)
message Book {
  string name = 1;
  uint32 page_count = 2;
}

If you need to violate this rule for an entire file, place the comment at the top of the file.