Closed randallmlough closed 4 years ago
I realized that getGoImportFromFile()
was being called for each import path, which either searches and opens a potential file (go.mod) or strips from a regex each time. In my opinion this is probably unnecessary since the import path isn't dynamic. It should be set on instantiation and the methods then refer to a field.
Thanks again for a high quality PR!
Enables go mod support and works outside of GOPATH directory. I left a few TODO comments in the funcs for review and more tests should be created, but this worked in my local testing both in GOPATH and outside using modules.
addresses issue #29
The approach I took: Since a go.mod file and processes works inside and outside of the GOPATH (as of 1.13 or 1.14 https://github.com/golang/go/issues/31857), I figured we could easily check whether or not a go.mod file exists in the working directory. If it does, we can open and read the file, retrieve the module path and move on. if not, use original method of getting import path from go/src