You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
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;
}
The text was updated successfully, but these errors were encountered:
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
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.
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
import_path
, define the base import path of import proto in generated code. Such aslilu.red/project_name
, son.pb.go will import father from:lilu.red/project_name/auto/grpc/father
package auto.grpc.father;
will generated directoryauto/grpc/father
. Its better to distinguish the same name struct in different package.Additional context
father.proto
son.proto
The text was updated successfully, but these errors were encountered: