-
Couldn't load subscription status.
- Fork 18.4k
Open
golang/tools
#601Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolProposalIssues describing a requested change to a Go tool or command-line program.Issues describing a requested change to a Go tool or command-line program.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.
Milestone
Description
Part of #63352
The current mechanism takes the last segment of the package path and appends a numeric suffix (if needed) to ensure uniqueness. This produces low-quality local names such path2, format3 and utils5.
I'm proposing potential strategies (2), (3) and (4), as illustrated below, to generate better names. These strategies follow common practices for package aliasing and result in more meaningful names.
- Try
PkgName(unchanged). - Try the local alias of the callee. (There is a todo comment in inline.go#525)
- Try
PkgName+"pkg". For example,pathbecomespathpkg. - Prepend the preceding path segment if available. For example,
golang.org/x/tools/internal/astutilbecomesinternalastutil. - Appending a numeric suffix (unchanged). For example,
pathbecomespath1,path2, ...
I'd love to implement these myself.
Alias examples in OSS repositories:
Strategy 3
- path as pathpkg: 14 usages in golang/tools, 11 usages in golang/go
- urlpkg, tracepkg, errorspkg, stringspkg, logpkg, htmlpkg, etc. in golang/go and golang/tools
- nodepkg, volumepkg, auditpkg, controllerpkg, etc. in kubernetes/kubernetes
Strategy 4
- internalastutil: 11 usages in golang/tools
- metav1: 2700+ usages in kubernetes/kubernetes
- apierrors: 564 usages in kubernetes/kubernetes
- utilerrors: 165 usages in kubernetes/kubernetes
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolProposalIssues describing a requested change to a Go tool or command-line program.Issues describing a requested change to a Go tool or command-line program.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.