Prefer non-internal packages in go doc shorthand lookup
Fixed Go's cmd/doc shorthand package lookup so go doc prefers public packages over internal packages when both share the same suffix.
golang/go · #80002
Problem
go doc synctest.Wait resolved to internal/synctest instead of testing/synctest because shorthand lookup returned the first matching suffix from the directory scan. That made public API documentation queries show the wrong package when an internal package appeared earlier.
Approach
Reworked shorthand package resolution to collect matching packages, defer internal path matches unless the query explicitly contains an internal path element, and preserve internal-package fallback when no public match exists. Added focused cmd/doc unit and script tests for public, missing-symbol, and only-internal lookup paths.
Impact and scope
- Improves Go CLI documentation accuracy for shorthand package queries such as synctest.Wait.
- Prevents internal implementation packages from shadowing public package documentation in normal lookups.
- Preserves explicit internal-package behavior and fallback semantics for cases where only an internal package exists.
Validation
- Added cmd/doc coverage proving synctest.Wait resolves to testing/synctest and not internal/synctest.
- Added a script test with public/internal package fixtures and an only-internal fallback case.
- Merged Gerrit CL passed Go review and trybot flow before submission to master.