forked from jhump/protoreflect
/
std_imports.go
50 lines (45 loc) · 1.68 KB
/
std_imports.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package protoparse
import (
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
// link in packages that include the standard protos included with protoc
_ "github.com/golang/protobuf/protoc-gen-go/plugin"
_ "github.com/golang/protobuf/ptypes/any"
_ "github.com/golang/protobuf/ptypes/duration"
_ "github.com/golang/protobuf/ptypes/empty"
_ "github.com/golang/protobuf/ptypes/struct"
_ "github.com/golang/protobuf/ptypes/timestamp"
_ "github.com/golang/protobuf/ptypes/wrappers"
_ "google.golang.org/genproto/protobuf/api"
_ "google.golang.org/genproto/protobuf/field_mask"
_ "google.golang.org/genproto/protobuf/ptype"
_ "google.golang.org/genproto/protobuf/source_context"
"github.com/xiaoshude/protoreflect/internal"
)
// All files that are included with protoc are also included with this package
// so that clients do not need to explicitly supply a copy of these protos (just
// like callers of protoc do not need to supply them).
var standardImports map[string]*dpb.FileDescriptorProto
func init() {
standardFilenames := []string{
"google/protobuf/any.proto",
"google/protobuf/api.proto",
"google/protobuf/compiler/plugin.proto",
"google/protobuf/descriptor.proto",
"google/protobuf/duration.proto",
"google/protobuf/empty.proto",
"google/protobuf/field_mask.proto",
"google/protobuf/source_context.proto",
"google/protobuf/struct.proto",
"google/protobuf/timestamp.proto",
"google/protobuf/type.proto",
"google/protobuf/wrappers.proto",
}
standardImports = map[string]*dpb.FileDescriptorProto{}
for _, fn := range standardFilenames {
fd, err := internal.LoadFileDescriptor(fn)
if err != nil {
panic(err.Error())
}
standardImports[fn] = fd
}
}