Skip to content

Commit

Permalink
Fix root dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinier Kors committed Aug 26, 2020
1 parent 9205d38 commit f44dc33
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
12 changes: 1 addition & 11 deletions goimportssort.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,9 @@ func isStandardPackage(pkg string) bool {
return ok
}

func getRootPath() (string, error) {
_, b, _, ok := runtime.Caller(0)
if !ok {
return "", errors.New("could not get root directory")
}
basepath := filepath.Dir(b)

return basepath, nil
}

// getModuleName parses the GOMOD name
func getModuleName() string {
root, err := getRootPath()
root, err := os.Getwd()
if err != nil {
log.Println("error when getting root path: ", err)
return ""
Expand Down
9 changes: 0 additions & 9 deletions goimportssort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,6 @@ func main() {
`, string(output))
}

func TestGetRootPath(t *testing.T) {
asserts := assert.New(t)

path, err := getRootPath()

asserts.Nil(err)
asserts.Contains(path, "goimportssort")
}

func TestGetModuleName(t *testing.T) {
asserts := assert.New(t)

Expand Down

0 comments on commit f44dc33

Please sign in to comment.