Protocol Buffers の .proto
ファイルの中で使用可能なスカラー型と、各言語の型の対応表です。
スカラー型は、メッセージ型 の各フィールドの型として使用できます。
protobuf | C++ | Java/Kotlin | Go | Dart |
---|---|---|---|---|
double |
double |
double |
float64 |
double |
float |
float |
float |
float32 |
double |
int32 |
int32 |
int |
int32 |
int |
int64 |
int64 |
long |
int64 |
Int64 |
uint32 |
uint32 |
int |
uint32 |
int |
uint64 |
uint64 |
long |
uint64 |
Int64 |
sint32 |
int32 |
int |
int32 |
int |
sint64 |
int64 |
long |
int64 |
Int64 |
fixed32 |
uint32 |
int |
uint32 |
int |
fixed64 |
uint64 |
long |
uint64 |
Int64 |
sfixed32 |
int32 |
int |
int32 |
int |
sfixed64 |
int64 |
long |
int64 |
Int64 |
bool |
bool |
boolean |
bool |
bool |
string |
string |
String |
string |
String |
bytes |
string |
ByteString |
[]byte |
List |
次のような repeated
フィールドは、配列やリスト(Golang ではスライス)に相当するコードに置き換えられます。
repeated float prices = 2; // Golang なら []float32 になる
repeated string snippets = 3; // Golang なら []string になる