slogUUIDFieldNameHasIDSuffix ensures that "uuid.UUID" field has ID prefix in the field name.
(m dsl.Matcher)
| 358 | // slogUUIDFieldNameHasIDSuffix ensures that "uuid.UUID" field has ID prefix |
| 359 | // in the field name. |
| 360 | func slogUUIDFieldNameHasIDSuffix(m dsl.Matcher) { |
| 361 | m.Import("cdr.dev/slog/v3") |
| 362 | m.Import("github.com/google/uuid") |
| 363 | m.Match( |
| 364 | `slog.F($name, $value)`, |
| 365 | ). |
| 366 | Where(m["value"].Type.Is("uuid.UUID") && !m["name"].Text.Matches(`_id"$`)). |
| 367 | Report(`uuid.UUID field $name must have "_id" suffix.`) |
| 368 | } |
| 369 | |
| 370 | // slogMessageFormat ensures that the log message starts with lowercase, and does not |
| 371 | // end with special character. |