fix(11.1-07): require built, run src= code; case-sensitive go doc; parse command forms

- .go src= targets must be in the default build and reached from a Test or an Example with output
- go doc -c makes the identifier fallback case-sensitive
- commandWord parses env prefixes, flags, go run and bin/ forms
This commit is contained in:
Jakub Zych
2026-10-01 08:37:38 +02:00
parent 73c72af244
commit efc3161c3f
4 changed files with 192 additions and 34 deletions

View File

@@ -284,10 +284,10 @@ func isUpper(s string) bool {
// optionally followed by one ".Member".
var goDocIdent = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?$`)
// goDoc is the fallback for an index miss: `go doc ./<dir> <query>` run in
// the repository root, so a declaration the index does not model still
// counts. It runs without a shell, on an argument list whose query matches
// goDocIdent.
// goDoc is the fallback for an index miss: `go doc -c ./<dir> <query>`
// run in the repository root, so a declaration the index does not model
// still counts. -c makes the match case-sensitive. It runs without a
// shell, on an argument list whose query matches goDocIdent.
func (idx *identIndex) goDoc(dir, query string) bool {
if !goDocIdent.MatchString(query) {
return false
@@ -298,7 +298,7 @@ func (idx *identIndex) goDoc(dir, query string) bool {
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, "go", "doc", "./"+dir, query)
cmd := exec.CommandContext(ctx, "go", "doc", "-c", "./"+dir, query)
cmd.Dir = idx.root
cmd.Stdout, cmd.Stderr = nil, nil
ok := cmd.Run() == nil