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