-
Notifications
You must be signed in to change notification settings - Fork 344
Include proto files from Go modules #498
Comments
If you specify an absolute path to your |
We could maybe add a new config flag So, the following would look in
This would look in
|
Thanks for the tip with E.g. this works: protoc:
version: 3.3.0
includes:
- /home/fgrosse/pkg/mod/example.com/foo/bar@v0.6.1
… Since this is not very practical a vendor mode in prototool would be very good. It should be possible given all information required can already be created using E.g. from the example, the following command would generate the path I used in the prototool.yml if I am inside a Go module that uses echo $GOPATH/pkg/mod/example.com/foo/bar@$(go list -m -f '{{.Version}}' example.com/foo/bar)
/home/fgrosse/pkg/mod/example.com/foo/bar@v0.6.1 |
Well actually looking into it, currently I don't see a way to access module information without having to execute However maybe we could be allowed to use environment variables in the imports? diff --git a/internal/settings/config_provider.go b/internal/settings/config_provider.go
index e8fa72f..e4d6353 100644
--- a/internal/settings/config_provider.go
+++ b/internal/settings/config_provider.go
@@ -204,6 +204,8 @@ func externalConfigToConfig(develMode bool, e ExternalConfig, dirPath string) (C
}
includePaths := make([]string, 0, len(e.Protoc.Includes))
for _, includePath := range strs.SortUniq(e.Protoc.Includes) {
+ includePath = os.ExpandEnv(includePath)
+
if !filepath.IsAbs(includePath) {
includePath = filepath.Join(dirPath, includePath)
} Then we could reference the modules directory if we know the version: protoc:
version: 3.3.0
includes:
- $GOPATH/pkg/mod/example.com/foo/bar@v0.6.1
… I would then put a CI validation script in place that will execute If that would be ok I can open the PR. |
This seems fine. Please make sure to update any docs to indicate that env variables are possible in imports. |
Hello, how is this going? |
Sorry, I got distracted and did not find time yet. Maybe I will have time on the weekend to return to this but if you want to submit a PR yourself go ahead :) |
Closing for now due to inactivity. Please reopen (or reference this issue) if a PR is created |
I want to include Protobuf definitions from another repository. So far this works nicely when I have a
vendor
directory with the followingprototool.yml
:Now I want to switch to Go modules (normal mode without vendor directory) and I am not sure how I can reference modules in the prototool includes directive. Is this a known use case somebody else already solved or is it simply not possible to include proto files from other Modules?
The text was updated successfully, but these errors were encountered: