2016-10-13 40 views
5

Ben grpc eklenti ve golangnasıl golang

Protoc ile google/protobuf/timestamp.proto kullanmaya çalışıyorum içinde grpc ile predifined protobuf tipini (yani "google/protobuf/timestamp.proto") kullanmak için - I ./ ./*.proto --go_out = plugins = grpc :.

#domain.proto 
syntax = "proto3"; 
option java_multiple_files = true; 
option java_package = "com.viant.xyz"; 
option java_outer_classname = "domain"; 

import "google/protobuf/timestamp.proto"; 

message Foo { 
    Timestamp modifiedTime = 1; 
    ... 
} 

Ben şu hataları görüyorum: Bu henüz desteklenmiyor

domain.proto: Import "google/protobuf/timestamp.proto" was not found or had errors. 
domain.proto:44:5: "Timestamp" is not defined. 

Ben bir şey eksik veya muyum, tamamen henüz desteklenmiyor

cevap

2

ama o iş yapabilir

message Foo { 
    google.protobuf.Timestamp modifiedTime = 1; 
    ... 
} 

değiştirerek ve dosya ithalat

oluşturulan sabitleme Kullanmak değiştirmek zorunda,

protoc -I/usr/local/include -I. --go_out=plugins=grpc:. *.proto 

Eğer timestamp.proto görebileceğiniz gibi, Timestamp pakette google.protobuf var:

import google_protobuf "google/protobuf/timestamp.pb" 

import google_protobuf "github.com/golang/protobuf/ptypes/timestamp" 
3

için /usr/local/include/google/api/timestamp.proto kullanmak yollarını içerecek şekilde /usr/local/include ekle böyle Timestamp:

message Foo { 
    google.protobuf.Timestamp modifiedTime = 1; 
    ... 
} 
0

Ben git grpc eklentisine bir Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp seçeneğini vererek soruna. Başka bir deyişle

, ben bir hack bir parçasıdır

protoc --go_out=plugins=grpc,Mgoogle/protobuf/timestamp.proto=github.com/golang/protobuf/ptypes/timestamp:outputdir input.proto 

aramıştım. "Neyse ki" yapı kurulumumda zaten çok sayıda Mprotofile=go/pkg/import/path parametresini kullanıyorum, bu yüzden eklenmesi kolay oldu.