gripmock
gripmock copied to clipboard
Proposal: add an option to force ignore go_package in proto files
Hi,
We are currently using full repo paths in go_package (e. g. option go_package = "github.com/v-makeev/private_repo";). Generated server.go file imports github.com/v-makeev/private_repo, which cannot be downloaded inside docker container without having an access to the private repo:
go: finding module for package github.com/v-makeev/private_repo
/go/src/grpc/server.go:20:2: cannot find module providing package github.com/v-makeev/private_repo: module github.com/v-makeev/private_repo: git ls-remote -q origin in /go/pkg/mod/cache/vcs/8dd17a4ce0e6ef02ebc2c8c18e5845e43eab6dc9f0bc58caabc9322d24fba487: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
I've tried using v1.11-beta and it works great when go_package is not present, but I'm wondering if there would be an option to force replace the original annotation before generating server.go.
This seem to require a few minor changes:
- add new CLI flag
- pass this flag to
fix_gopackage.sh - if the flag is set, replace the annotation instead of exiting the script
Hmm this is interesting, so you mean gripmock should override your go_package declaration, right?
In another word, it seems this issue is affecting everyone with go_package declared in v1-11-beta.
thanks @v-makeev for the feedback, it's a valid bug.
I think what I'm going to do is append the replace statement in gripmock mod.go
replace github.com/v-makeev/private_repo v0.0.0 => /go/src/github.com/v-makeev/private_repo
this will trick Go inside the image to look for local package instead.
Turns out it is too hard to create the replace statement for each package. So I force-replace the go_package as a default behaviour, since any declaration of it will break the system due to the latest go mod update. :smile: #114