Skip to content

Commit

Permalink
cmd/go/internal/vet: print line numbers appropriately on list errors
Browse files Browse the repository at this point in the history
Fixes golang#36173

For reasons that are unclear to me, this commit:
golang@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.
  • Loading branch information
nicks committed Feb 14, 2020
1 parent 753d56d commit ca2984b
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 85 deletions.
8 changes: 3 additions & 5 deletions src/cmd/go/internal/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
stk.Push(arg)
err := downloadPackage(p)
if err != nil {
base.Errorf("%s", &load.PackageError{ImportStack: stk.Copy(), Err: err})
base.Errorf("%s", load.NewPackageError(stk, err))
stk.Pop()
return
}
Expand Down Expand Up @@ -353,10 +353,8 @@ func download(arg string, parent *load.Package, stk *load.ImportStack, mode int)
}
if j, ok := load.FindVendor(orig); ok {
stk.Push(path)
err := &load.PackageError{
ImportStack: stk.Copy(),
Err: load.ImportErrorf(path, "%s must be imported as %s", path, path[j+len("vendor/"):]),
}
err := load.NewPackageError(stk,
load.ImportErrorf(path, "%s must be imported as %s", path, path[j+len("vendor/"):]))
stk.Pop()
base.Errorf("%s", err)
continue
Expand Down
Loading

0 comments on commit ca2984b

Please sign in to comment.