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

Using pacakges.NeedName #418

Merged
merged 1 commit into from
Mar 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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