Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Using pacakges.NeedName (#418)
Browse files Browse the repository at this point in the history
packages.LoadFiles is deprecated. It is not future-proof to use it. In addition, I found all mockgen need is Package.PkgPath, so packages.NeedName is sufficient.
  • Loading branch information
linzhp authored Mar 28, 2020
1 parent 0b87a54 commit ccaa079
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mockgen/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,11 @@ func packageNameOfDir(srcDir string) (string, error) {

// parseImportPackage get package import path via source file
func parsePackageImport(source, srcDir string) (string, error) {
cfg := &packages.Config{Mode: packages.LoadFiles, Tests: true, Dir: srcDir}
cfg := &packages.Config{
Mode: packages.NeedName,
Tests: true,
Dir: srcDir,
}
pkgs, err := packages.Load(cfg, "file="+source)
if err != nil {
return "", err
Expand Down

0 comments on commit ccaa079

Please sign in to comment.