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

Support generated code use package in right way without option go_package #791

Closed
alx696 opened this issue Jan 18, 2019 · 1 comment
Closed

Comments

@alx696
Copy link

alx696 commented Jan 18, 2019

Is your feature request related to a problem? Please describe.
Without option go_package, generated code lost import define, have different package name but placed in one directory.

Describe the solution you'd like
Auto generated code with package in right way.

Describe alternatives you've considered

  1. Re-use import_path, define the base import path of import proto in generated code. Such as lilu.red/project_name, son.pb.go will import father from: lilu.red/project_name/auto/grpc/father
  2. Generate folders like Java. package auto.grpc.father; will generated directory auto/grpc/father. Its better to distinguish the same name struct in different package.

Currently: option go_package need to be defined in every proto file, and not support batch generation #790 . package auto.grpc.son in generated code is package auto_grpc_son, lost import, and put then in same place(Golang not allow different package in one directory)!!

Additional context
father.proto

syntax = "proto3";

package auto.grpc.father;
//option go_package = "lilu.red/proto/auto/grpc/father";

message Info {
  string name = 1;
}

son.proto

syntax = "proto3";

package auto.grpc.son;
//option go_package = "lilu.red/proto/auto/grpc/son";

import "father.proto";

service SonService {
  rpc Insert (Info) returns (Info) {
  }
}

message Info {
  string id = 1; //auto set
  string name = 2;
  father.Info father = 3;
}
@alx696 alx696 changed the title Support generated code with package without option go_package Support generated code use package in right way without option go_package Jan 18, 2019
@dsnet
Copy link
Member

dsnet commented Jul 10, 2019

We're moving towards a world where we double down on the presence of go_package. Any logic that tries to derive the Go package path from the information in protobuf alone leads to insanity in some way or another. The go_package option is the only way to have a sane understanding of how proto files relate to one another in the Go language.

@dsnet dsnet closed this as completed Jul 10, 2019
@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants