folder structure
service.proto
`
syntax = “proto3”;
package service;
option go_package = "../../../proto-generated/user/service";
import "user/models/models.proto";
service UserService {
rpc CreateUser(models.CreateUserRequest) returns (models.CreateUserResponse);
rpc GetUser(models.GetUserRequest) returns (models.GetUserResponse);
}
`
models.proto
`
syntax = “proto3”;
package models;
option go_package = "../../../proto-generated/user/models";
message CreateUserRequest {
string username = 1;
int32 age = 2;
}
message CreateUserResponse {
int32 id = 1;
}
message GetUserRequest {
int32 id = 1;
}
message GetUserResponse {
int32 id = 1;
string username = 2;
int32 age = 3;
}
`
I tried to create proto files using
protoc -I=. –go_out=. models.proto
and
protoc -I=. –go-grpc_out=. service.proto
by going in respective directory,
models proto is getting created successfully, as it doesn’t contains any import
however service generation is failing
error: user/models/models.proto: File not found.
New contributor
Praveen Kumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.