blob: 775f920377cdcdc7ca6b8d8225252885e01917a4 [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"
Joe Tsaid8881392019-06-06 13:01:53 -070016 "google.golang.org/protobuf/internal/filetype"
Damien Neile89e6242019-05-13 23:55:40 -070017 "google.golang.org/protobuf/internal/impl"
Damien Neil8012b442019-01-18 09:32:24 -080018)
Joe Tsaif9123a32018-11-30 09:04:58 +000019
Joe Tsai58b42d82019-05-22 16:27:51 -040020const (
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 Tsaie1f8d502018-11-26 18:55:29 -080025
Joe Tsai58b42d82019-05-22 16:27:51 -040026 // 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 Tsaif9123a32018-11-30 09:04:58 +000035
Joe Tsaic0e4bb22019-07-06 13:05:11 -070036// UnsafeEnabled specifies whether package unsafe can be used.
37const UnsafeEnabled = impl.UnsafeEnabled
38
Joe Tsaie1f8d502018-11-26 18:55:29 -080039type (
40 // EnforceVersion is used by code generated by protoc-gen-go
Joe Tsai58b42d82019-05-22 16:27:51 -040041 // 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 Tsaie1f8d502018-11-26 18:55:29 -080045 //
Joe Tsai58b42d82019-05-22 16:27:51 -040046 // 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 Tsaie1f8d502018-11-26 18:55:29 -080051 //
52 // Example usage by generated code:
Joe Tsai58b42d82019-05-22 16:27:51 -040053 // 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 Tsaie1f8d502018-11-26 18:55:29 -080059 //
Joe Tsai58b42d82019-05-22 16:27:51 -040060 // 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 Tsaie1f8d502018-11-26 18:55:29 -080063 EnforceVersion uint
64
Joe Tsai52ec1752019-08-05 15:49:29 -070065 DescBuilder = filedesc.Builder
66 TypeBuilder = filetype.Builder
Joe Tsai82760ce2019-06-20 03:09:57 -070067 Pointer = impl.Pointer
Joe Tsai378c1322019-04-25 23:48:08 -070068 MessageInfo = impl.MessageInfo
Joe Tsai82760ce2019-06-20 03:09:57 -070069 MessageState = impl.MessageState
Joe Tsai378c1322019-04-25 23:48:08 -070070 SizeCache = impl.SizeCache
Joe Tsai3d8e3692019-04-08 13:52:14 -070071 WeakFields = impl.WeakFields
Joe Tsai378c1322019-04-25 23:48:08 -070072 UnknownFields = impl.UnknownFields
73 ExtensionFields = impl.ExtensionFields
Joe Tsai89d49632019-06-04 16:20:00 -070074 ExtensionFieldV1 = impl.ExtensionField
Joe Tsaie1f8d502018-11-26 18:55:29 -080075)
Joe Tsai58b42d82019-05-22 16:27:51 -040076
77var X impl.Export