Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: add an option to force ignore go_package in proto files #105

Open
v-makeev opened this issue Mar 1, 2022 · 3 comments
Open

Proposal: add an option to force ignore go_package in proto files #105

v-makeev opened this issue Mar 1, 2022 · 3 comments

Comments

@v-makeev
Copy link

v-makeev commented Mar 1, 2022

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
@jekiapp
Copy link
Contributor

jekiapp commented Jun 10, 2022

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.

@jekiapp
Copy link
Contributor

jekiapp commented Jun 10, 2022

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.

@jekiapp
Copy link
Contributor

jekiapp commented Jun 15, 2022

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. 😄
#114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants