Documentation
¶
Overview ¶
Package stringbytesroundtrip implements a Go analysis linter that flags two related but semantically distinct patterns:
- string([]byte(s)) when s is already a string: genuinely redundant — the result is value-identical to s and both conversions can be removed.
- []byte(string(b)) when b is already a []byte: not redundant but wasteful — this is the defensive-copy idiom that produces a non-aliasing clone via two copies; prefer slices.Clone(b) or bytes.Clone(b) for a single copy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Analyzer = &analysis.Analyzer{ Name: "stringbytesroundtrip", Doc: "reports string([]byte(s)) as a redundant round-trip when s is already a string, and []byte(string(b)) as a wasteful two-copy clone when b is already a []byte (prefer slices.Clone or bytes.Clone)", URL: "https://github.com/github/gh-aw/tree/main/pkg/linters/stringbytesroundtrip", Requires: []*analysis.Analyzer{inspect.Analyzer, nolint.Analyzer, filecheck.Analyzer}, Run: run, }
Analyzer is the string-bytes-roundtrip analysis pass.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.