.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 -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私は私の答えにその道を言いました! –