stringbytesroundtrip

package
v0.83.3 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 7 Imported by: 0

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.

Jump to

Keyboard shortcuts

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