trimleftright

package
v0.82.14 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package trimleftright implements a Go analysis linter that flags calls to strings.TrimLeft or strings.TrimRight with a multi-character string literal cutset, where strings.TrimPrefix or strings.TrimSuffix is almost certainly the intended function.

strings.TrimLeft(s, "foo") does NOT remove the prefix "foo"; it removes any leading rune that appears anywhere in the cutset characters 'f', 'o'. This is a well-known Go gotcha.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     "trimleftright",
	Doc:      "reports likely mistaken strings.TrimLeft/TrimRight calls using multi-character alphanumeric literal cutsets",
	URL:      "https://github.com/github/gh-aw/tree/main/pkg/linters/trimleftright",
	Requires: []*analysis.Analyzer{inspect.Analyzer, nolint.Analyzer, filecheck.Analyzer},
	Run:      run,
}

Analyzer is the trimleftright 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