24 ) |
24 ) |
25 |
25 |
26 // EnforceVersion is used by code generated by protoc-gen-go |
26 // EnforceVersion is used by code generated by protoc-gen-go |
27 // to statically enforce minimum and maximum versions of this package. |
27 // to statically enforce minimum and maximum versions of this package. |
28 // A compilation failure implies either that: |
28 // A compilation failure implies either that: |
29 // * the runtime package is too old and needs to be updated OR |
29 // - the runtime package is too old and needs to be updated OR |
30 // * the generated code is too old and needs to be regenerated. |
30 // - the generated code is too old and needs to be regenerated. |
31 // |
31 // |
32 // The runtime package can be upgraded by running: |
32 // The runtime package can be upgraded by running: |
|
33 // |
33 // go get google.golang.org/protobuf |
34 // go get google.golang.org/protobuf |
34 // |
35 // |
35 // The generated code can be regenerated by running: |
36 // The generated code can be regenerated by running: |
|
37 // |
36 // protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES} |
38 // protoc --go_out=${PROTOC_GEN_GO_ARGS} ${PROTO_FILES} |
37 // |
39 // |
38 // Example usage by generated code: |
40 // Example usage by generated code: |
|
41 // |
39 // const ( |
42 // const ( |
40 // // Verify that this generated code is sufficiently up-to-date. |
43 // // Verify that this generated code is sufficiently up-to-date. |
41 // _ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion) |
44 // _ = protoimpl.EnforceVersion(genVersion - protoimpl.MinVersion) |
42 // // Verify that runtime/protoimpl is sufficiently up-to-date. |
45 // // Verify that runtime/protoimpl is sufficiently up-to-date. |
43 // _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion) |
46 // _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - genVersion) |
47 // This compile-time check relies on negative integer overflow of a uint |
50 // This compile-time check relies on negative integer overflow of a uint |
48 // being a compilation failure (guaranteed by the Go specification). |
51 // being a compilation failure (guaranteed by the Go specification). |
49 type EnforceVersion uint |
52 type EnforceVersion uint |
50 |
53 |
51 // This enforces the following invariant: |
54 // This enforces the following invariant: |
|
55 // |
52 // MinVersion ≤ GenVersion ≤ MaxVersion |
56 // MinVersion ≤ GenVersion ≤ MaxVersion |
53 const ( |
57 const ( |
54 _ = EnforceVersion(GenVersion - MinVersion) |
58 _ = EnforceVersion(GenVersion - MinVersion) |
55 _ = EnforceVersion(MaxVersion - GenVersion) |
59 _ = EnforceVersion(MaxVersion - GenVersion) |
56 ) |
60 ) |