diff --git a/mockgen/mockgen.go b/mockgen/mockgen.go index 7fe3770..1b615b1 100644 --- a/mockgen/mockgen.go +++ b/mockgen/mockgen.go @@ -130,7 +130,11 @@ func main() { // is output into an already existing package. outputPackagePath := *selfPackage if outputPackagePath == "" && *destination != "" { - dstPath, err := filepath.Abs(filepath.Dir(*destination)) + currentDir,err:=os.Getwd() + if err != nil { + log.Fatalf("%v",err) + } + dstPath, err := filepath.Abs(filepath.Dir(strings.Join([]string{currentDir,*destination},string(os.PathSeparator)))) if err == nil { pkgPath, err := parsePackageImport(dstPath) if err == nil { diff --git a/mockgen/parse.go b/mockgen/parse.go index f43321c..7234ed2 100644 --- a/mockgen/parse.go +++ b/mockgen/parse.go @@ -37,7 +37,11 @@ import ( // sourceMode generates mocks via source file. func sourceMode(source string) (*model.Package, error) { - srcDir, err := filepath.Abs(filepath.Dir(source)) + currentDir,err:=os.Getwd() + if err != nil { + return nil, fmt.Errorf("%v",err) + } + srcDir, err := filepath.Abs(filepath.Dir(strings.Join([]string{currentDir,source},string(os.PathSeparator)))) if err != nil { return nil, fmt.Errorf("failed getting source directory: %v", err) }