impl.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. // UnsafeEnabled specifies whether package unsafe can be used.
  30. const UnsafeEnabled = impl.UnsafeEnabled
  31. type (
  32. // EnforceVersion is used by code generated by protoc-gen-go
  33. // to statically enforce minimum and maximum versions of this package.
  34. // A compilation failure implies either that:
  35. // * the runtime package is too old and needs to be updated OR
  36. // * the generated code is too old and needs to be regenerated.
  37. //
  38. // The runtime package can be upgraded by running:
  39. // go get google.golang.org/protobuf
  40. //
  41. // The generated code can be regenerated by running:
  42. // protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES}
  43. //
  44. // Example usage by generated code:
  45. // const (
  46. // // Verify that runtime/protoimpl is sufficiently up-to-date.
  47. // _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion)
  48. // // Verify that this generated code is sufficiently up-to-date.
  49. // _ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion)
  50. // )
  51. //
  52. // The genVersion is the current version used to generated the code.
  53. // This compile-time check relies on negative integer overflow of a uint
  54. // being a compilation failure (guaranteed by the Go specification).
  55. EnforceVersion uint
  56. DescBuilder = filedesc.DescBuilder
  57. TypeBuilder = filetype.TypeBuilder
  58. Pointer = impl.Pointer
  59. MessageInfo = impl.MessageInfo
  60. MessageState = impl.MessageState
  61. SizeCache = impl.SizeCache
  62. WeakFields = impl.WeakFields
  63. UnknownFields = impl.UnknownFields
  64. ExtensionFields = impl.ExtensionFields
  65. ExtensionFieldV1 = impl.ExtensionField
  66. )
  67. var X impl.Export