From 2fe5d15858832896e87d56e95e9d797fd18ef57b Mon Sep 17 00:00:00 2001 From: Abhishekkarunakaran Date: Thu, 25 Apr 2024 07:11:44 +0530 Subject: [PATCH] feat: Changed the values of -source & -destination flags to relative path This absolute path values felt redundant. --- mockgen/mockgen.go | 6 +++++- mockgen/parse.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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) }