Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 1 | // Copyright 2019 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 proto provides functions operating on protocol buffer messages. |
| 6 | // |
| 7 | // For documentation on protocol buffers in general, see: |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 8 | // https://protobuf.dev. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 9 | // |
| 10 | // For a tutorial on using protocol buffers with Go, see: |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 11 | // https://protobuf.dev/getting-started/gotutorial. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 12 | // |
| 13 | // For a guide to generated Go protocol buffer code, see: |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 14 | // https://protobuf.dev/reference/go/go-generated. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 15 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 16 | // # Binary serialization |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 17 | // |
| 18 | // This package contains functions to convert to and from the wire format, |
| 19 | // an efficient binary serialization of protocol buffers. |
| 20 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 21 | // - [Size] reports the size of a message in the wire format. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 22 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 23 | // - [Marshal] converts a message to the wire format. |
| 24 | // The [MarshalOptions] type provides more control over wire marshaling. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 25 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 26 | // - [Unmarshal] converts a message from the wire format. |
| 27 | // The [UnmarshalOptions] type provides more control over wire unmarshaling. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 28 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 29 | // # Basic message operations |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 30 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 31 | // - [Clone] makes a deep copy of a message. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 32 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 33 | // - [Merge] merges the content of a message into another. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 34 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 35 | // - [Equal] compares two messages. For more control over comparisons |
| 36 | // and detailed reporting of differences, see package |
| 37 | // [google.golang.org/protobuf/testing/protocmp]. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 38 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 39 | // - [Reset] clears the content of a message. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 40 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 41 | // - [CheckInitialized] reports whether all required fields in a message are set. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 42 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 43 | // # Optional scalar constructors |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 44 | // |
| 45 | // The API for some generated messages represents optional scalar fields |
| 46 | // as pointers to a value. For example, an optional string field has the |
| 47 | // Go type *string. |
| 48 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 49 | // - [Bool], [Int32], [Int64], [Uint32], [Uint64], [Float32], [Float64], and [String] |
| 50 | // take a value and return a pointer to a new instance of it, |
| 51 | // to simplify construction of optional field values. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 52 | // |
| 53 | // Generated enum types usually have an Enum method which performs the |
| 54 | // same operation. |
| 55 | // |
| 56 | // Optional scalar fields are only supported in proto2. |
| 57 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 58 | // # Extension accessors |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 59 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 60 | // - [HasExtension], [GetExtension], [SetExtension], and [ClearExtension] |
| 61 | // access extension field values in a protocol buffer message. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 62 | // |
| 63 | // Extension fields are only supported in proto2. |
| 64 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 65 | // # Related packages |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 66 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 67 | // - Package [google.golang.org/protobuf/encoding/protojson] converts messages to |
| 68 | // and from JSON. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 69 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 70 | // - Package [google.golang.org/protobuf/encoding/prototext] converts messages to |
| 71 | // and from the text format. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 72 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 73 | // - Package [google.golang.org/protobuf/reflect/protoreflect] provides a |
| 74 | // reflection interface for protocol buffer data types. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 75 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 76 | // - Package [google.golang.org/protobuf/testing/protocmp] provides features |
| 77 | // to compare protocol buffer messages with the [github.com/google/go-cmp/cmp] |
| 78 | // package. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 79 | // |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 80 | // - Package [google.golang.org/protobuf/types/dynamicpb] provides a dynamic |
| 81 | // message type, suitable for working with messages where the protocol buffer |
| 82 | // type is only known at runtime. |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 83 | // |
| 84 | // This module contains additional packages for more specialized use cases. |
| 85 | // Consult the individual package documentation for details. |
| 86 | package proto |