.proto 파일을 컴파일하는 데 문제가 있습니다. .proto 파일에서 REST 엔드 포인트를 생성하려고합니다. 아래는 코드와 오류입니다 : syntax = "proto3";.proto에서 REST 끝점을 자동 생성합니다.
package pb;
import "google/protobuf/empty.proto";
import "google/api/annotations.proto";
service UrlShortener {
rpc Hello(HelloRequest) returns (HelloResponse);
rpc Encrypt(EncryptRequest) returns (EncryptResponse);
rpc Decrypt(DecryptRequest) returns (DecryptResponse) {
option (google.api.http) = {
get: "/{hash}"
};
}
}
message HelloRequest {
string Name = 1;
}
message HelloResponse {
string Message = 1;
}
message EncryptRequest {
string OriginalUrl = 1;
}
message EncryptResponse {
UrlMap ResponseMap = 1;
}
message DecryptRequest {
string hash = 1;
}
오류 : 가 github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis : 경고 : 디렉토리가 존재하지 않습니다. google/api/annotations.proto : 파일을 찾을 수 없습니다. urlshortener.proto : "google/api/annotations.proto"가져 오기를 찾을 수 없거나 오류가있었습니다.
문제를 해결하는 데 도움을주십시오.
시도 : go get -u github.com/grpc-ecosystem/grpc-gateway 하지만 경로에 소스 파일을 빌드 할 수 없습니다.
구문 = "proto3을"이동; 내 파일에 jus가 위의 코드 블록에 남았습니다. UrlMap 구조체도 마찬가지입니다. 붙여 넣기 편집되지 않은 버전에 대해 사과드립니다. 문제는 google/api/annotations가 이전 경로 인 grpc-ecosystem/grpc-gateway/third_party/googleapis에서 옮겨 졌음을 알게되었습니다. 다음 작업을 수행하면 오류가 해결되었습니다. go -u github.com/grpc-ecosystem/grpc-gateway/ ... – zaRRoc
@Mayank 나는 내 대답에서 그 경로를 언급했습니다! –