Open 1st-vil opened 7 months ago
@rillig Hello. Thank you for developing this useful tool 🙇♂️
I'd like to contribute gobco and create PR on this issue to resolve it sooner. Is it good for you? and could you tell me some points of caution on contributing this repo if there is it?
Hello @1st-vil, you found pretty nice use cases, and you explanation is easy to follow. If you have an idea on how to reliably determine the import path of the current package, I'm welcoming a pull request of yours. My idea would be to search for a go.mod
file in the current directory and its parent directories. The code in writeGobcoBlackBox
may be a good starting point.
There are no points of caution, just go ahead. :)
Hi @rillig. I created a PR on this issue. So I'd like you to review it 🙇♂️
@rillig If we merge the PR, I'd like you to publish next release including it after fix. It's because I'd like to use this in fixed version that is ensured not to change. Is it ok?
@rillig Hello. I'd appreciate it if you could see my PR 🙇
@1st-vil Sorry that it took me so long to reply.
Thank you for the PR showing that the module can be found.
Right now, gobco does not have any external dependencies, and I'd like to keep this property.
For just finding the module path, there is no need to verify the hashes, so I'd like to omit these dependencies. Another point I don't understand is why the PR adds dependencies for 5 different versions of golang.org/x/mod
; I'd think that a single version should be enough.
@rillig Sorry that it took me so long to reply too...
I'm also not sure about why the PR adds dependencies for 5 different versions of golang.org/x/mod
. I just used golang.org/x/mod/modfile
. But I found that we can use exec.Command("go", "list", "-m")
instead to get a module name. By doing this, There will not be those dependencies.
Could you check my changes again?
@rillig Hi. Could you see my PR again 🙇
Overview
In a directory with multiple package (Maybe they are
something
andsomething_test
), it tries to find the package's path ofsomething
. It is performed by looking for its direct importimport "github.com/org/repo/something"
in the directory. here: https://github.com/rillig/gobco/blob/master/instrumenter.go#L623-L643Maybe it expects there is such import in a file with
something_test
package. But, in some cases like it uses another package as helper, the import may not be in the directory. So there are need to provide secure way to determine the package's path.Example
it can't find the path
something/something.go
something/something_test.go
helper/helper.go
For above files, error like below occurred.
It find incorrect path with same package name
interface/something/something.go
something/factory.go
something/something.go
something/something_test.go
helper/helper.go
For above files, error like below occurred.