blob: 8470dbec5f5749f69affee399ab9a9b5866fd94e [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 (
Joe Tsaid8881392019-06-06 13:01:53 -070015 "google.golang.org/protobuf/internal/filedesc"
Damien Neile89e6242019-05-13 23:55:40 -070016 "google.golang.org/protobuf/internal/fileinit"
Joe Tsaid8881392019-06-06 13:01:53 -070017 "google.golang.org/protobuf/internal/filetype"
Damien Neile89e6242019-05-13 23:55:40 -070018 "google.golang.org/protobuf/internal/impl"
Damien Neil8012b442019-01-18 09:32:24 -080019)
Joe Tsaif9123a32018-11-30 09:04:58 +000020
Joe Tsai58b42d82019-05-22 16:27:51 -040021const (
22 // MaxVersion is the maximum supported version for generated .pb.go files;
23 // which is the current version of the package.
24 // This is incremented when the functionality of this package expands.
25 MaxVersion = 0
Joe Tsaie1f8d502018-11-26 18:55:29 -080026
Joe Tsai58b42d82019-05-22 16:27:51 -040027 // MinVersion is the minimum supported version for generated .pb.go files.
28 // This is incremented when the runtime drops support for old code.
29 MinVersion = 0
30
31 // Version is the current minor version of the runtime.
32 Version = MaxVersion // v2.{Version}.x
33
34 // TODO: Encode a date instead of the minor version?
35)
Joe Tsaif9123a32018-11-30 09:04:58 +000036
Joe Tsaie1f8d502018-11-26 18:55:29 -080037type (
38 // EnforceVersion is used by code generated by protoc-gen-go
Joe Tsai58b42d82019-05-22 16:27:51 -040039 // to statically enforce minimum and maximum versions of this package.
40 // A compilation failure implies either that:
41 // * the runtime package is too old and needs to be updated OR
42 // * the generated code is too old and needs to be regenerated.
Joe Tsaie1f8d502018-11-26 18:55:29 -080043 //
Joe Tsai58b42d82019-05-22 16:27:51 -040044 // The runtime package can be upgraded by running:
45 // go get google.golang.org/protobuf
46 //
47 // The generated code can be regenerated by running:
48 // protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES}
Joe Tsaie1f8d502018-11-26 18:55:29 -080049 //
50 // Example usage by generated code:
Joe Tsai58b42d82019-05-22 16:27:51 -040051 // const (
52 // // Verify that runtime/protoimpl is sufficiently up-to-date.
53 // _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion)
54 // // Verify that this generated code is sufficiently up-to-date.
55 // _ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion)
56 // )
Joe Tsaie1f8d502018-11-26 18:55:29 -080057 //
Joe Tsai58b42d82019-05-22 16:27:51 -040058 // The genVersion is the current version used to generated the code.
59 // This compile-time check relies on negative integer overflow of a uint
60 // being a compilation failure (guaranteed by the Go specification).
Joe Tsaie1f8d502018-11-26 18:55:29 -080061 EnforceVersion uint
62
Joe Tsaid8881392019-06-06 13:01:53 -070063 FileBuilder = fileinit.FileBuilder // TODO: Remove this.
64 DescBuilder = filedesc.DescBuilder
65 TypeBuilder = filetype.TypeBuilder
Joe Tsai378c1322019-04-25 23:48:08 -070066 MessageInfo = impl.MessageInfo
67 SizeCache = impl.SizeCache
68 UnknownFields = impl.UnknownFields
69 ExtensionFields = impl.ExtensionFields
Joe Tsai89d49632019-06-04 16:20:00 -070070 ExtensionFieldV1 = impl.ExtensionField
Joe Tsaie1f8d502018-11-26 18:55:29 -080071)
Joe Tsai58b42d82019-05-22 16:27:51 -040072
73var X impl.Export