Skip to content

Commit ca2984b

Browse files
committed
cmd/go/internal/vet: print line numbers appropriately on list errors
Fixes #36173 For reasons that are unclear to me, this commit: f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
1 parent 753d56d commit ca2984b

File tree

7 files changed

+255
-85
lines changed

7 files changed

+255
-85
lines changed

src/cmd/go/internal/get/get.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
274274
stk.Push(arg)
275275
err := downloadPackage(p)
276276
if err != nil {
277-
base.Errorf("%s", &load.PackageError{ImportStack: stk.Copy(), Err: err})
277+
base.Errorf("%s", load.NewPackageError(stk, err))
278278
stk.Pop()
279279
return
280280
}
@@ -353,10 +353,8 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
353353
}
354354
if j, ok := load.FindVendor(orig); ok {
355355
stk.Push(path)
356-
err := &load.PackageError{
357-
ImportStack: stk.Copy(),
358-
Err: load.ImportErrorf(path, "%s must be imported as %s", path, path[j+len("vendor/"):]),
359-
}
356+
err := load.NewPackageError(stk,
357+
load.ImportErrorf(path, "%s must be imported as %s", path, path[j+len("vendor/"):]))
360358
stk.Pop()
361359
base.Errorf("%s", err)
362360
continue

0 commit comments

Comments
 (0)