The linters package namespace contains custom static analysis linters used by gh-aw quality checks.
This package currently provides custom Go analyzers in the following subpackages:
appendbytestring— reportsappend(b, []byte(s)...)calls wherebis[]byteandsis a string, which can be simplified toappend(b, s...).bytescomparestring— reportsstring(a) == string(b)andstring(a) != string(b)comparisons whereaandbare[]bytevalues that should usebytes.Equal.contextcancelnotdeferred— reports context cancel functions that are called directly instead of deferred.ctxbackground— reportscontext.Background()calls inside functions that already receive acontext.Contextparameter.deferinloop— reportsdeferstatements placed directly insidefor/rangeloop bodies, which execute when the enclosing function returns rather than each iteration and can cause resource leaks.errorfwrapv— reportsfmt.Errorfcalls that format error arguments with%vinstead of%w.excessivefuncparams— reports function declarations that exceed a configurable parameter-count threshold.errormessage— reports non-actionable error-message patterns in changed files.errortypeassertion— reports type assertions fromerrorto concrete types and recommendserrors.As.errstringmatch— reportsstrings.Contains(err.Error(), "...")patterns and recommendserrors.Is/errors.As.fileclosenotdeferred— reports non-deferred fileClose()calls that can leak resources.execcommandwithoutcontext— reportsexec.Command(...)calls inside functions that already receivecontext.Contextand should useexec.CommandContext(...).fmterrorfnoverbs— reportsfmt.Errorfcalls whose format string contains no verbs, recommendingerrors.Newinstead.fprintlnsprintf— reportsfmt.Fprintln(..., fmt.Sprintf(...))patterns and recommends direct formatting calls.hardcodedfilepath— reports hard-coded file path string literals that match known path constants or should be extracted into named constants; also annotates paths that appear in log/print calls.httpnoctx— reports HTTP client and package-level HTTP calls that do not accept acontext.Context.httprespbodyclose— reports HTTP responses whoseBody.Close()call is missing or not deferred.httpstatuscode— reports raw HTTP status-code integer literals that should usenet/httpnamed constants.jsonmarshalignoredeerror— reportsjson.Marshalandjson.Unmarshalcalls where the error return is discarded.largefunc— reports function bodies that exceed a configurable line-count threshold.lenstringsplit— reportslen(strings.Split(s, sep))expressions with a non-empty separator that should usestrings.Count(s, sep)+1to avoid an intermediate slice allocation.lenstringzero— reportslen(s) == 0/len(s) != 0comparisons on string values that should uses == ""/s != "".manualmutexunlock— reports non-deferred mutexUnlock()calls that can lead to deadlocks on early returns or panics.osgetenvlibrary— reportsos.Getenvcalls in library packages (pkg/*) where environment access should be injected.osexitinlibrary— reportsos.Exitcalls in library packages (pkg/*) where process termination should be delegated tocmd/*entry points.ossetenvlibrary— reportsos.Setenvcalls in library packages (pkg/*) where side effects should be isolated.panic-in-library-code— reportspanic()calls in library packages (pkg/*) where errors should be returned instead.rawloginlib— reports direct usage of the standardlogpackage in library packages, wherepkg/loggershould be used.regexpcompileinfunction— reportsregexp.MustCompile/regexp.Compilecalls inside functions that should be package-level.seenmapbool— reportsmap[string]boolused as a set (values alwaystrue) that should usemap[string]struct{}instead.sortslice— reportssort.Slice/sort.SliceStablecalls that should useslices.SortFunc/slices.SortStableFunc.sprintferrdot— reports redundant.Error()calls on error values passed tofmtformat functions where the fmt package calls.Error()automatically.sprintferrorsnew— reportserrors.New(fmt.Sprintf(...))calls that should usefmt.Errorfinstead.sprintfint— reportsfmt.Sprintf("%d", ...)and related conversions that should usestrconvhelpers.ssljson— validatesssl.jsonskill artifacts found in.github/skills/against the SSL spec (enum membership, graph integrity, transition targets, entry pointer validity).strconvparseignorederror— reportsstrconvparsing calls (Atoi,ParseInt, etc.) where the error return is discarded with_.stringreplaceminusone— reportsstrings.Replacecalls whosenargument is-1, which should use the more readablestrings.ReplaceAll.stringsindexcontains— reportsstrings.Index(s, substr)comparisons with-1or0(e.g.!= -1,>= 0,> -1,== -1,< 0,<= -1) and their yoda-order variants that should usestrings.Contains(s, substr)or!strings.Contains(s, substr)instead.timeafterleak— reportstime.Aftercalls used as the channel-receive expression in aselectcase inside afororrangeloop that leak a timer channel on each iteration when another case fires first.timesleepnocontext— reportstime.Sleepcalls inside functions that already receive acontext.Context, where a context-awareselectshould be used instead.tolowerequalfold— reports case-insensitive string comparisons usingstrings.ToLower/ToUpperthat should usestrings.EqualFold.uncheckedtypeassertion— reports single-value type assertions where unchecked panics are possible.wgdonenotdeferred— reports non-deferredsync.WaitGroup.Done()calls that can deadlock on panics or early returns.writebytestring— reportsw.Write([]byte(s))calls wheresis a string, which can be replaced withio.WriteStringto avoid an unnecessary[]byteallocation.internal— shared helper packages for analyzers (file checks andnolinthandling).
| Subpackage | Description |
|---|---|
appendbytestring |
Custom go/analysis analyzer that flags append(b, []byte(s)...) calls where s is a string that can be simplified to append(b, s...) |
bytescomparestring |
Custom go/analysis analyzer that flags string(a) == string(b) / != comparisons on []byte values that should use bytes.Equal |
contextcancelnotdeferred |
Custom go/analysis analyzer that flags context cancel functions called directly instead of deferred |
ctxbackground |
Custom go/analysis analyzer that flags context.Background() calls inside functions that already receive a context parameter |
deferinloop |
Custom go/analysis analyzer that flags defer statements inside for/range loop bodies that execute when the enclosing function returns rather than each iteration |
errorfwrapv |
Custom go/analysis analyzer that flags fmt.Errorf calls that format error arguments with %v instead of %w |
excessivefuncparams |
Custom go/analysis analyzer that flags function declarations with too many positional parameters |
errormessage |
Custom go/analysis analyzer that flags non-actionable error message patterns in changed files |
errortypeassertion |
Custom go/analysis analyzer that flags type assertions from error to concrete types and recommends errors.As |
errstringmatch |
Custom go/analysis analyzer that flags brittle strings.Contains(err.Error(), "...") checks |
execcommandwithoutcontext |
Custom go/analysis analyzer that flags exec.Command(...) calls that should use exec.CommandContext(...) in context-receiving functions |
fileclosenotdeferred |
Custom go/analysis analyzer that flags file Close() calls that are not deferred immediately |
fmterrorfnoverbs |
Custom go/analysis analyzer that flags fmt.Errorf calls with no format verbs, recommending errors.New |
fprintlnsprintf |
Custom go/analysis analyzer that flags fmt.Fprintln(..., fmt.Sprintf(...)) patterns |
hardcodedfilepath |
Custom go/analysis analyzer that flags hard-coded file path string literals that match known path constants or should be extracted as named constants; annotates paths in log/print calls |
httpnoctx |
Custom go/analysis analyzer that flags HTTP calls that do not accept a context.Context |
httprespbodyclose |
Custom go/analysis analyzer that flags HTTP response bodies that are not closed (or not deferred) |
httpstatuscode |
Custom go/analysis analyzer that flags raw HTTP status-code integer literals that should use net/http named constants |
jsonmarshalignoredeerror |
Custom go/analysis analyzer that flags json.Marshal/json.Unmarshal calls where the error return is discarded |
largefunc |
Custom go/analysis analyzer that flags large functions with actionable diagnostics |
lenstringsplit |
Custom go/analysis analyzer that flags len(strings.Split(s, sep)) with a non-empty separator that should use strings.Count(s, sep)+1 |
lenstringzero |
Custom go/analysis analyzer that flags len(s) == 0 / len(s) != 0 on string values that should use s == "" / s != "" |
manualmutexunlock |
Custom go/analysis analyzer that flags mutex Unlock() calls that are not deferred |
osgetenvlibrary |
Custom go/analysis analyzer that flags os.Getenv usage in library packages |
osexitinlibrary |
Custom go/analysis analyzer that flags os.Exit usage in library packages |
ossetenvlibrary |
Custom go/analysis analyzer that flags os.Setenv usage in library packages |
panic-in-library-code |
Custom go/analysis analyzer that flags panic() usage in library packages |
rawloginlib |
Custom go/analysis analyzer that flags standard-library log package calls in library packages |
regexpcompileinfunction |
Custom go/analysis analyzer that flags regexp compilation inside function bodies |
seenmapbool |
Custom go/analysis analyzer that flags map[string]bool used as a set that should use map[string]struct{} |
sortslice |
Custom go/analysis analyzer that flags sort.Slice / sort.SliceStable calls that should use slices.SortFunc / slices.SortStableFunc |
sprintferrdot |
Custom go/analysis analyzer that flags redundant .Error() calls on error values passed to fmt format functions |
sprintferrorsnew |
Custom go/analysis analyzer that flags errors.New(fmt.Sprintf(...)) calls that should use fmt.Errorf instead |
sprintfint |
Custom go/analysis analyzer that flags fmt.Sprintf integer conversions that should use strconv helpers |
ssljson |
Custom go/analysis analyzer that validates SSL JSON skill artifacts in .github/skills/ |
strconvparseignorederror |
Custom go/analysis analyzer that flags strconv parsing calls where the error return is discarded with _ |
stringreplaceminusone |
Custom go/analysis analyzer that flags strings.Replace calls with n=-1 that should use strings.ReplaceAll |
stringsindexcontains |
Custom go/analysis analyzer that flags strings.Index(s, substr) comparisons with -1 or 0 that should use strings.Contains or !strings.Contains |
timeafterleak |
Custom go/analysis analyzer that flags time.After in select cases inside loops that leak a timer channel on each iteration when another case fires first |
timesleepnocontext |
Custom go/analysis analyzer that flags time.Sleep calls in context-aware functions |
tolowerequalfold |
Custom go/analysis analyzer that flags case-insensitive comparisons via strings.ToLower/ToUpper that should use strings.EqualFold |
uncheckedtypeassertion |
Custom go/analysis analyzer that flags unchecked single-value type assertions |
wgdonenotdeferred |
Custom go/analysis analyzer that flags non-deferred sync.WaitGroup.Done() calls |
writebytestring |
Custom go/analysis analyzer that flags w.Write([]byte(s)) calls where s is a string that can be replaced with io.WriteString |
internal |
Shared helper subpackages used by analyzers (internal/filecheck, internal/nolint) |
| Symbol | Description |
|---|---|
ErrorMessageAnalyzer |
Compatibility alias to pkg/linters/errormessage.Analyzer |
import (
"github.com/github/gh-aw/pkg/linters/deferinloop"
"github.com/github/gh-aw/pkg/linters/errorfwrapv"
"github.com/github/gh-aw/pkg/linters/ctxbackground"
"github.com/github/gh-aw/pkg/linters/excessivefuncparams"
"github.com/github/gh-aw/pkg/linters/errormessage"
"github.com/github/gh-aw/pkg/linters/errstringmatch"
"github.com/github/gh-aw/pkg/linters/execcommandwithoutcontext"
"github.com/github/gh-aw/pkg/linters/fileclosenotdeferred"
"github.com/github/gh-aw/pkg/linters/hardcodedfilepath"
"github.com/github/gh-aw/pkg/linters/httpnoctx"
"github.com/github/gh-aw/pkg/linters/httprespbodyclose"
"github.com/github/gh-aw/pkg/linters/httpstatuscode"
"github.com/github/gh-aw/pkg/linters/largefunc"
"github.com/github/gh-aw/pkg/linters/lenstringzero"
"github.com/github/gh-aw/pkg/linters/manualmutexunlock"
"github.com/github/gh-aw/pkg/linters/osgetenvlibrary"
"github.com/github/gh-aw/pkg/linters/osexitinlibrary"
panicinlibrarycode "github.com/github/gh-aw/pkg/linters/panic-in-library-code"
"github.com/github/gh-aw/pkg/linters/rawloginlib"
"github.com/github/gh-aw/pkg/linters/regexpcompileinfunction"
"github.com/github/gh-aw/pkg/linters/sortslice"
"github.com/github/gh-aw/pkg/linters/sprintfint"
"github.com/github/gh-aw/pkg/linters/ssljson"
"github.com/github/gh-aw/pkg/linters/timesleepnocontext"
)
// Use with multichecker, singlechecker, or custom go/analysis driver.
_ = ctxbackground.Analyzer
_ = deferinloop.Analyzer
_ = errorfwrapv.Analyzer
_ = excessivefuncparams.Analyzer
_ = errormessage.Analyzer
_ = errstringmatch.Analyzer
_ = execcommandwithoutcontext.Analyzer
_ = fileclosenotdeferred.Analyzer
_ = hardcodedfilepath.Analyzer
_ = httpnoctx.Analyzer
_ = httprespbodyclose.Analyzer
_ = httpstatuscode.Analyzer
_ = largefunc.Analyzer
_ = lenstringzero.Analyzer
_ = manualmutexunlock.Analyzer
_ = osgetenvlibrary.Analyzer
_ = osexitinlibrary.Analyzer
_ = panicinlibrarycode.Analyzer
_ = rawloginlib.Analyzer
_ = regexpcompileinfunction.Analyzer
_ = sortslice.Analyzer
_ = sprintfint.Analyzer
_ = ssljson.Analyzer
_ = timesleepnocontext.AnalyzerInternal:
github.com/github/gh-aw/pkg/linters/appendbytestring— append-byte-string analyzer subpackagegithub.com/github/gh-aw/pkg/linters/bytescomparestring— bytes-compare-string analyzer subpackagegithub.com/github/gh-aw/pkg/linters/contextcancelnotdeferred— context-cancel-not-deferred analyzer subpackagegithub.com/github/gh-aw/pkg/linters/ctxbackground— context-background analyzer subpackagegithub.com/github/gh-aw/pkg/linters/deferinloop— defer-in-loop analyzer subpackagegithub.com/github/gh-aw/pkg/linters/errorfwrapv— fmt-errorf-wrap-v analyzer subpackagegithub.com/github/gh-aw/pkg/linters/errormessage— error-message analyzer subpackage (also re-exported asErrorMessageAnalyzer)github.com/github/gh-aw/pkg/linters/errortypeassertion— error-type-assertion analyzer subpackagegithub.com/github/gh-aw/pkg/linters/errstringmatch— err-string-match analyzer subpackagegithub.com/github/gh-aw/pkg/linters/execcommandwithoutcontext— exec-command-without-context analyzer subpackagegithub.com/github/gh-aw/pkg/linters/excessivefuncparams— excessive-func-params analyzer subpackagegithub.com/github/gh-aw/pkg/linters/fileclosenotdeferred— file-close-not-deferred analyzer subpackagegithub.com/github/gh-aw/pkg/linters/fmterrorfnoverbs— fmt-errorf-no-verbs analyzer subpackagegithub.com/github/gh-aw/pkg/linters/fprintlnsprintf— fprintln-sprintf analyzer subpackagegithub.com/github/gh-aw/pkg/linters/hardcodedfilepath— hard-coded-file-path analyzer subpackagegithub.com/github/gh-aw/pkg/linters/httpnoctx— HTTP-no-context analyzer subpackagegithub.com/github/gh-aw/pkg/linters/httprespbodyclose— HTTP-response-body-close analyzer subpackagegithub.com/github/gh-aw/pkg/linters/httpstatuscode— http-status-code analyzer subpackagegithub.com/github/gh-aw/pkg/linters/jsonmarshalignoredeerror— json-marshal-ignored-error analyzer subpackagegithub.com/github/gh-aw/pkg/linters/largefunc— large-func analyzer subpackagegithub.com/github/gh-aw/pkg/linters/lenstringsplit— len-strings-split analyzer subpackagegithub.com/github/gh-aw/pkg/linters/lenstringzero— len-string-zero analyzer subpackagegithub.com/github/gh-aw/pkg/linters/manualmutexunlock— manual-mutex-unlock analyzer subpackagegithub.com/github/gh-aw/pkg/linters/osgetenvlibrary— os-getenv-library analyzer subpackagegithub.com/github/gh-aw/pkg/linters/osexitinlibrary— os-exit-in-library analyzer subpackagegithub.com/github/gh-aw/pkg/linters/ossetenvlibrary— os-setenv-library analyzer subpackagegithub.com/github/gh-aw/pkg/linters/panic-in-library-code— panic-in-library-code analyzer subpackagegithub.com/github/gh-aw/pkg/linters/rawloginlib— raw-log-in-lib analyzer subpackagegithub.com/github/gh-aw/pkg/linters/regexpcompileinfunction— regexp-compile-in-function analyzer subpackagegithub.com/github/gh-aw/pkg/linters/seenmapbool— seen-map-bool analyzer subpackagegithub.com/github/gh-aw/pkg/linters/sortslice— sort-slice analyzer subpackagegithub.com/github/gh-aw/pkg/linters/sprintferrdot— sprintf-err-dot analyzer subpackagegithub.com/github/gh-aw/pkg/linters/sprintferrorsnew— sprintf-errors-new analyzer subpackagegithub.com/github/gh-aw/pkg/linters/sprintfint— sprintf-int analyzer subpackagegithub.com/github/gh-aw/pkg/linters/ssljson— ssl-json analyzer subpackagegithub.com/github/gh-aw/pkg/linters/strconvparseignorederror— strconv-parse-ignored-error analyzer subpackagegithub.com/github/gh-aw/pkg/linters/stringreplaceminusone— string-replace-minus-one analyzer subpackagegithub.com/github/gh-aw/pkg/linters/stringsindexcontains— strings-index-contains analyzer subpackagegithub.com/github/gh-aw/pkg/linters/timeafterleak— time-after-leak analyzer subpackagegithub.com/github/gh-aw/pkg/linters/timesleepnocontext— time-sleep-no-context analyzer subpackagegithub.com/github/gh-aw/pkg/linters/tolowerequalfold— to-lower-equal-fold analyzer subpackagegithub.com/github/gh-aw/pkg/linters/uncheckedtypeassertion— unchecked-type-assertion analyzer subpackagegithub.com/github/gh-aw/pkg/linters/wgdonenotdeferred— wg-done-not-deferred analyzer subpackagegithub.com/github/gh-aw/pkg/linters/writebytestring— write-byte-string analyzer subpackage
Transitive / Internal helpers:
github.com/github/gh-aw/pkg/linters/internal/filecheck— shared file-path filtering helpers used by multiple analyzersgithub.com/github/gh-aw/pkg/linters/internal/nolint— shared//nolintdirective parsing helpers used by multiple analyzers
External:
golang.org/x/tools/go/analysis— analyzer frameworkgolang.org/x/tools/go/analysis/passes/inspect— AST inspection supportgolang.org/x/tools/go/ast/inspector— efficient AST traversal
- The package is intentionally organized as a namespace (
pkg/linters/*) so individual analyzers remain isolated and independently testable. - CI currently enforces the
errstringmatch,manualmutexunlock,panicinlibrarycode,osexitinlibrary, andrawloginlibanalyzers via.github/workflows/cgo.yml. excessivefuncparamsexposes a-max-paramsanalyzer flag and defaults to8parameters (DefaultMaxParams).largefuncexposes a-max-linesanalyzer flag, defaults to60lines (DefaultMaxLines), and skips_test.gofiles.osexitinlibraryhelps enforce separation between library logic and process-level termination.
This specification is automatically maintained by the spec-extractor workflow.