Help us shape the future of Go! Take the 2026 Go Developer Survey

stringbytesroundtrip

package
v0.92.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package stringbytesroundtrip implements a Go analysis linter that flags two related but semantically distinct patterns:

  • string([]byte(s)) when the result and s have the predeclared string type: genuinely redundant — the result is value-identical to s and both conversions can be removed. For named string types, the inner conversion can still be removed, but an outer conversion may be necessary.
  • []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 = analyzerutil.New("stringbytesroundtrip", "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)", run)

Analyzer is the string-bytes-roundtrip analysis pass.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL