Joe Tsai | f9123a3 | 2018-11-30 09:04:58 +0000 | [diff] [blame] | 1 | // Copyright 2018 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // Package protoimpl contains the default implementation for messages |
| 6 | // generated by protoc-gen-go. |
| 7 | // |
| 8 | // WARNING: This package should only ever be imported by generated messages. |
| 9 | // The compatibility agreement covers nothing except for functionality needed |
| 10 | // to keep existing generated messages operational. Breakages that occur due |
| 11 | // to unauthorized usages of this package are not the author's responsibility. |
| 12 | package protoimpl |
| 13 | |
Damien Neil | 8012b44 | 2019-01-18 09:32:24 -0800 | [diff] [blame] | 14 | import ( |
Joe Tsai | d888139 | 2019-06-06 13:01:53 -0700 | [diff] [blame] | 15 | "google.golang.org/protobuf/internal/filedesc" |
Joe Tsai | d888139 | 2019-06-06 13:01:53 -0700 | [diff] [blame] | 16 | "google.golang.org/protobuf/internal/filetype" |
Damien Neil | e89e624 | 2019-05-13 23:55:40 -0700 | [diff] [blame] | 17 | "google.golang.org/protobuf/internal/impl" |
Damien Neil | 8012b44 | 2019-01-18 09:32:24 -0800 | [diff] [blame] | 18 | ) |
Joe Tsai | f9123a3 | 2018-11-30 09:04:58 +0000 | [diff] [blame] | 19 | |
Joe Tsai | 58b42d8 | 2019-05-22 16:27:51 -0400 | [diff] [blame] | 20 | const ( |
| 21 | // MaxVersion is the maximum supported version for generated .pb.go files; |
| 22 | // which is the current version of the package. |
| 23 | // This is incremented when the functionality of this package expands. |
| 24 | MaxVersion = 0 |
Joe Tsai | e1f8d50 | 2018-11-26 18:55:29 -0800 | [diff] [blame] | 25 | |
Joe Tsai | 58b42d8 | 2019-05-22 16:27:51 -0400 | [diff] [blame] | 26 | // MinVersion is the minimum supported version for generated .pb.go files. |
| 27 | // This is incremented when the runtime drops support for old code. |
| 28 | MinVersion = 0 |
| 29 | |
| 30 | // Version is the current minor version of the runtime. |
| 31 | Version = MaxVersion // v2.{Version}.x |
| 32 | |
| 33 | // TODO: Encode a date instead of the minor version? |
| 34 | ) |
Joe Tsai | f9123a3 | 2018-11-30 09:04:58 +0000 | [diff] [blame] | 35 | |
Joe Tsai | c0e4bb2 | 2019-07-06 13:05:11 -0700 | [diff] [blame] | 36 | // UnsafeEnabled specifies whether package unsafe can be used. |
| 37 | const UnsafeEnabled = impl.UnsafeEnabled |
| 38 | |
Joe Tsai | e1f8d50 | 2018-11-26 18:55:29 -0800 | [diff] [blame] | 39 | type ( |
| 40 | // EnforceVersion is used by code generated by protoc-gen-go |
Joe Tsai | 58b42d8 | 2019-05-22 16:27:51 -0400 | [diff] [blame] | 41 | // to statically enforce minimum and maximum versions of this package. |
| 42 | // A compilation failure implies either that: |
| 43 | // * the runtime package is too old and needs to be updated OR |
| 44 | // * the generated code is too old and needs to be regenerated. |
Joe Tsai | e1f8d50 | 2018-11-26 18:55:29 -0800 | [diff] [blame] | 45 | // |
Joe Tsai | 58b42d8 | 2019-05-22 16:27:51 -0400 | [diff] [blame] | 46 | // The runtime package can be upgraded by running: |
| 47 | // go get google.golang.org/protobuf |
| 48 | // |
| 49 | // The generated code can be regenerated by running: |
| 50 | // protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES} |
Joe Tsai | e1f8d50 | 2018-11-26 18:55:29 -0800 | [diff] [blame] | 51 | // |
| 52 | // Example usage by generated code: |
Joe Tsai | 58b42d8 | 2019-05-22 16:27:51 -0400 | [diff] [blame] | 53 | // const ( |
| 54 | // // Verify that runtime/protoimpl is sufficiently up-to-date. |
| 55 | // _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion) |
| 56 | // // Verify that this generated code is sufficiently up-to-date. |
| 57 | // _ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion) |
| 58 | // ) |
Joe Tsai | e1f8d50 | 2018-11-26 18:55:29 -0800 | [diff] [blame] | 59 | // |
Joe Tsai | 58b42d8 | 2019-05-22 16:27:51 -0400 | [diff] [blame] | 60 | // The genVersion is the current version used to generated the code. |
| 61 | // This compile-time check relies on negative integer overflow of a uint |
| 62 | // being a compilation failure (guaranteed by the Go specification). |
Joe Tsai | e1f8d50 | 2018-11-26 18:55:29 -0800 | [diff] [blame] | 63 | EnforceVersion uint |
| 64 | |
Joe Tsai | 52ec175 | 2019-08-05 15:49:29 -0700 | [diff] [blame^] | 65 | DescBuilder = filedesc.Builder |
| 66 | TypeBuilder = filetype.Builder |
Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 67 | Pointer = impl.Pointer |
Joe Tsai | 378c132 | 2019-04-25 23:48:08 -0700 | [diff] [blame] | 68 | MessageInfo = impl.MessageInfo |
Joe Tsai | 82760ce | 2019-06-20 03:09:57 -0700 | [diff] [blame] | 69 | MessageState = impl.MessageState |
Joe Tsai | 378c132 | 2019-04-25 23:48:08 -0700 | [diff] [blame] | 70 | SizeCache = impl.SizeCache |
Joe Tsai | 3d8e369 | 2019-04-08 13:52:14 -0700 | [diff] [blame] | 71 | WeakFields = impl.WeakFields |
Joe Tsai | 378c132 | 2019-04-25 23:48:08 -0700 | [diff] [blame] | 72 | UnknownFields = impl.UnknownFields |
| 73 | ExtensionFields = impl.ExtensionFields |
Joe Tsai | 89d4963 | 2019-06-04 16:20:00 -0700 | [diff] [blame] | 74 | ExtensionFieldV1 = impl.ExtensionField |
Joe Tsai | e1f8d50 | 2018-11-26 18:55:29 -0800 | [diff] [blame] | 75 | ) |
Joe Tsai | 58b42d8 | 2019-05-22 16:27:51 -0400 | [diff] [blame] | 76 | |
| 77 | var X impl.Export |