【发布时间】:2019-06-11 20:57:50
【问题描述】:
在使用dep 时,我无法包含google/protobuf/timestamp.proto 众所周知的类型。
我收到一个错误:google/protobuf/timestamp.proto: File not found
service.proto:
syntax = "proto3";
import "google/protobuf/timestamp.proto";
package com.rynop.platform;
option go_package = "rpc";
service PlatformService {
rpc Test(EmptyMessage) returns (EmptyMessage);
}
message EmptyMessage { }
message A {
string summary = 1;
google.protobuf.Timestamp start = 2;
}
message B {
repeated A foos = 1;
}
安装包含时间戳的包 .proto def:
dep ensure -add github.com/golang/protobuf/ptypes/timestamp
运行protoc 并得到错误:
build/bin/protoc -Ivendor -I. --twirp_typescript_out=version=v6:./clients/ts-json/ rpc/service.proto
google/protobuf/timestamp.proto: File not found.
包含时间戳的 .proto 定义的目录存在:
file vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto
vendor/github.com/golang/protobuf/ptypes/timestamp/timestamp.proto: ASCII text
我正在本地安装 protoc,因为我不想将 protoc 版本锁定/绑定到该项目:
# fetch the protoc compiler
OS_NAME=$(shell uname -s)
ifeq ($(OS_NAME),Darwin)
PROTOC_URL=https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-osx-x86_64.zip
endif
ifeq ($(OS_NAME),Linux)
PROTOC_URL=https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip
endif
build/protoc build/bin/protoc:
mkdir -p build/protoc/bin build/bin
cd build/protoc && curl -L -o protoc.zip $(PROTOC_URL) && \
unzip protoc.zip && mv bin/protoc ../bin/protoc
我做错了什么?
【问题讨论】:
标签: go protocol-buffers protoc twirp