Skip to content

Commit 81c8ef2

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 81c8ef2

File tree

8 files changed

+260
-93
lines changed

8 files changed

+260
-93
lines changed

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

+6-8
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
271271
// Download if the package is missing, or update if we're using -u.
272272
if p.Dir == "" || *getU {
273273
// The actual download.
274-
stk.Push(arg)
274+
stk.Push(arg, nil)
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
}
@@ -329,7 +329,7 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
329329
if isWildcard {
330330
// Report both the real package and the
331331
// wildcard in any error message.
332-
stk.Push(p.ImportPath)
332+
stk.Push(p.ImportPath, nil)
333333
}
334334

335335
// Process dependencies, now that we know what they are.
@@ -352,11 +352,9 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
352352
orig = p.Internal.Build.Imports[i]
353353
}
354354
if j, ok := load.FindVendor(orig); ok {
355-
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-
}
355+
stk.Push(path, nil)
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)