blob: 59198a68f3e5c91a52d99b9f1e1f45e089c6f287 [file] [log] [blame]
Joe Tsaif9123a32018-11-30 09:04:58 +00001// 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.
12package protoimpl
13
Damien Neil8012b442019-01-18 09:32:24 -080014import (
Damien Neile89e6242019-05-13 23:55:40 -070015 "google.golang.org/protobuf/internal/fileinit"
16 "google.golang.org/protobuf/internal/impl"
Damien Neil8012b442019-01-18 09:32:24 -080017)
Joe Tsaif9123a32018-11-30 09:04:58 +000018
Joe Tsai58b42d82019-05-22 16:27:51 -040019const (
20 // MaxVersion is the maximum supported version for generated .pb.go files;
21 // which is the current version of the package.
22 // This is incremented when the functionality of this package expands.
23 MaxVersion = 0
Joe Tsaie1f8d502018-11-26 18:55:29 -080024
Joe Tsai58b42d82019-05-22 16:27:51 -040025 // MinVersion is the minimum supported version for generated .pb.go files.
26 // This is incremented when the runtime drops support for old code.
27 MinVersion = 0
28
29 // Version is the current minor version of the runtime.
30 Version = MaxVersion // v2.{Version}.x
31
32 // TODO: Encode a date instead of the minor version?
33)
Joe Tsaif9123a32018-11-30 09:04:58 +000034
Joe Tsaie1f8d502018-11-26 18:55:29 -080035type (
36 // EnforceVersion is used by code generated by protoc-gen-go
Joe Tsai58b42d82019-05-22 16:27:51 -040037 // to statically enforce minimum and maximum versions of this package.
38 // A compilation failure implies either that:
39 // * the runtime package is too old and needs to be updated OR
40 // * the generated code is too old and needs to be regenerated.
Joe Tsaie1f8d502018-11-26 18:55:29 -080041 //
Joe Tsai58b42d82019-05-22 16:27:51 -040042 // The runtime package can be upgraded by running:
43 // go get google.golang.org/protobuf
44 //
45 // The generated code can be regenerated by running:
46 // protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES}
Joe Tsaie1f8d502018-11-26 18:55:29 -080047 //
48 // Example usage by generated code:
Joe Tsai58b42d82019-05-22 16:27:51 -040049 // const (
50 // // Verify that runtime/protoimpl is sufficiently up-to-date.
51 // _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion)
52 // // Verify that this generated code is sufficiently up-to-date.
53 // _ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion)
54 // )
Joe Tsaie1f8d502018-11-26 18:55:29 -080055 //
Joe Tsai58b42d82019-05-22 16:27:51 -040056 // The genVersion is the current version used to generated the code.
57 // This compile-time check relies on negative integer overflow of a uint
58 // being a compilation failure (guaranteed by the Go specification).
Joe Tsaie1f8d502018-11-26 18:55:29 -080059 EnforceVersion uint
60
Joe Tsai378c1322019-04-25 23:48:08 -070061 FileBuilder = fileinit.FileBuilder
62 MessageInfo = impl.MessageInfo
63 SizeCache = impl.SizeCache
64 UnknownFields = impl.UnknownFields
65 ExtensionFields = impl.ExtensionFields
Joe Tsai89d49632019-06-04 16:20:00 -070066 ExtensionFieldV1 = impl.ExtensionField
Joe Tsaie1f8d502018-11-26 18:55:29 -080067)
Joe Tsai58b42d82019-05-22 16:27:51 -040068
69var X impl.Export