scancode-toolkit
scancode-toolkit copied to clipboard
Support directives in go.mod
Short Description
We do not support all go.mod features such as replace directives in go.mod files and we should. See:
- https://github.com/golang/gofrontend/tree/d04b024021bb7dbaa434a6d902bd12beb08e315f/libgo/go/golang.org/x/mod/modfile
- https://go.dev/ref/mod#go-mod-file
- and https://github.com/nexB/scancode-toolkit/blob/develop/src/packagedcode/go_mod.py
And an example see https://github.com/golang/tools/blob/9425c2e70961cb8c2a3b5764658fb70e03d194e4/gopls/go.mod and https://github.com/golang/tools/blob/9425c2e70961cb8c2a3b5764658fb70e03d194e4/go.mod
Hey @pombredanne and @AyanSinhaMahapatra, I have raised a PR for the replace directive, but had doubts regardings the best way to approach some of the the things, listed below. Would it be possible to share some suggestions on how to best approach these?
-
What should be the scope for the original and replaced modules? Would replace be fine for both of them or should one be require and other be replace?
-
If a package is in both require and replace directives, we will have 2 instances of the same package listed? Is that ok or is there a way to deal with that?
For example in the go.mod of milvus (added in the PR), packages likegithub.com/expr-lang/exprandgithub.com/streamnative/pulsarctlare there both in the require as well in replace directives. This might be a very common scenario, as many a times a go developer might want to test an application with a local version or forked version of a dependency package, rather than using the original package -
How do we deal with the replacement package if the replacement points to a local path like
replace github.com/milvus-io/milvus/pkg => ./pkg? `