writeName writes a string as-is if it complies with the legacy naming scheme, or escapes it in double quotes if not.
(w enhancedWriter, name string)
| 510 | // writeName writes a string as-is if it complies with the legacy naming |
| 511 | // scheme, or escapes it in double quotes if not. |
| 512 | func writeName(w enhancedWriter, name string) (int, error) { |
| 513 | if model.LegacyValidation.IsValidMetricName(name) { |
| 514 | return w.WriteString(name) |
| 515 | } |
| 516 | var written int |
| 517 | var err error |
| 518 | err = w.WriteByte('"') |
| 519 | written++ |
| 520 | if err != nil { |
| 521 | return written, err |
| 522 | } |
| 523 | var n int |
| 524 | n, err = writeEscapedString(w, name, true) |
| 525 | written += n |
| 526 | if err != nil { |
| 527 | return written, err |
| 528 | } |
| 529 | err = w.WriteByte('"') |
| 530 | written++ |
| 531 | return written, err |
| 532 | } |
no test coverage detected
searching dependent graphs…