#785·go-tools

Unused unexported methods/others.

Author: albfCreated Jun 14, 2020Updated May 31, 2026

Hi there dominikh,

As a side project, I developed a checker that seems to go a bit further regarding unexported methods/values than what's currently present in staticcheck. What it identifies (all unexported definitions):

  • global constants and variables (type assertions are ignored).
  • structs and fields (assign-only is considered non-used).
  • interfaces and its methods.
  • functions, its arguments and return values (except main/init and cgo functions).
  • methods and, as functions, arguments/return values (methods that match interfaces are ignored).
  • functions/methods that are used as a value (therefore hard to detect) are also ignored to avoid false positives.

Current version uses SSA analysis and I believe at least the last two are not present - checking for argument usage or return values. Is there any interest in adding such a feature? I've been using it for a while in some large prod code bases and the results seem very useful.

Cheers,

Alex