-
Notifications
You must be signed in to change notification settings - Fork 345
Fix go_package
option behaviour on go proto API v2
#549
Comments
meet the same issue |
I have the same issue |
it seems that there is a conflict between this import_path, output dir, and defining the path in the proto file. The weirdness can be seen in the import patth of the generated files, which import other generated files. I worked around this problem with bash (moving files up one directory) |
I would like to chime in on this issue. We have found another issue with linting rules, specifically FILE_OPTIONS_EQUAL_GO_PACKAGE_V2_SUFFIX. The problem is it checks for equality only. So when you disable FILE_OPTIONS_GO_PACKAGE_NOT_LONG_FORM, you cannot use syntax like Since API v2 also requires full path in go_package, it would seem like fixing the issue above is also a requirement. Most likely by introducing FILE_OPTIONS_SUFFIX_GO_PACKAGE_V2_SUFFIX that checks go_package suffix or something like that. |
We have the same issue. |
Seeing the same issue! |
We found a workaround though I'm not sure if this works for everyone else. For everyone facing a similar issue they can try it out, if it fits with their project setup. Note that this workaround require to have full Ideally it'll be nice if the package path in proto files matches the generate:
go_options:
import_path: github.com/foo/protobuf
extra_modifiers:
google/api/annotations.proto: google.golang.org/genproto/googleapis/api/annotations
google/api/http.proto: google.golang.org/genproto/googleapis/api/annotations
plugins:
# using relative path ../ and generate the protobuf/grpc code in the parent directory
- name: go
type: go
flags: plugins=grpc,paths=source_relative
output: ../protobuf
- name: grpc-gateway
type: go
flags: paths=source_relative
output: ../protobuf On a side note, there is a new flag For more information on |
Please consider this issue for v1.11.0 |
This solution does not work for me. |
Managing to mostly work around this by applying a similar configuration to @arunk-s, but disabling the relevant linting rules:
With this, code generation and linting checks are completing successfully, with package declarations like We are also running |
First, A big Thanks for open-sourcing and maintaining
prototool
.Since the release of new protobuf API v2 for Golang, option
go_package
is now required to provide full import path.This collides with the current recommendations from
prototool
.When using
protoc-gen-go
APIv1 implemented in the terms of APIv2 at version1.4.0
, prototool generates the following warning.Note that there is a separate option to provide
paths=source_relative
flag toprotoc-gen-go
which changes the path of the output fields to relative paths. But that doesn't help with the above warnings.I'll leave the final decision of how prototool will incorporate the changes required for the new APIv2 on the maintainers.
But what I would love to see as a suggested change is:
import_path
or removal of theimport_path
entirely.protoc-gen-go
versions>1.3.4
if the change in behaviour ofimport_path
is backward incompatible forprototool
as long as the generated code is not impacted.The text was updated successfully, but these errors were encountered: