impl.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. // Package protoimpl contains the default implementation for messages
  5. // generated by protoc-gen-go.
  6. //
  7. // WARNING: This package should only ever be imported by generated messages.
  8. // The compatibility agreement covers nothing except for functionality needed
  9. // to keep existing generated messages operational. Breakages that occur due
  10. // to unauthorized usages of this package are not the author's responsibility.
  11. package protoimpl
  12. import (
  13. "google.golang.org/protobuf/internal/filedesc"
  14. "google.golang.org/protobuf/internal/filetype"
  15. "google.golang.org/protobuf/internal/impl"
  16. )
  17. const (
  18. // MaxVersion is the maximum supported version for generated .pb.go files;
  19. // which is the current version of the package.
  20. // This is incremented when the functionality of this package expands.
  21. MaxVersion = 0
  22. // MinVersion is the minimum supported version for generated .pb.go files.
  23. // This is incremented when the runtime drops support for old code.
  24. MinVersion = 0
  25. // Version is the current minor version of the runtime.
  26. Version = MaxVersion // v2.{Version}.x
  27. // TODO: Encode a date instead of the minor version?
  28. )
  29. type (
  30. // EnforceVersion is used by code generated by protoc-gen-go
  31. // to statically enforce minimum and maximum versions of this package.
  32. // A compilation failure implies either that:
  33. // * the runtime package is too old and needs to be updated OR
  34. // * the generated code is too old and needs to be regenerated.
  35. //
  36. // The runtime package can be upgraded by running:
  37. // go get google.golang.org/protobuf
  38. //
  39. // The generated code can be regenerated by running:
  40. // protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES}
  41. //
  42. // Example usage by generated code:
  43. // const (
  44. // // Verify that runtime/protoimpl is sufficiently up-to-date.
  45. // _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion)
  46. // // Verify that this generated code is sufficiently up-to-date.
  47. // _ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion)
  48. // )
  49. //
  50. // The genVersion is the current version used to generated the code.
  51. // This compile-time check relies on negative integer overflow of a uint
  52. // being a compilation failure (guaranteed by the Go specification).
  53. EnforceVersion uint
  54. DescBuilder = filedesc.DescBuilder
  55. TypeBuilder = filetype.TypeBuilder
  56. MessageInfo = impl.MessageInfo
  57. SizeCache = impl.SizeCache
  58. UnknownFields = impl.UnknownFields
  59. ExtensionFields = impl.ExtensionFields
  60. ExtensionFieldV1 = impl.ExtensionField
  61. )
  62. var X impl.Export