aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/gob
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2022-02-03 14:12:08 -0500
committerRuss Cox <rsc@golang.org>2022-04-11 16:34:30 +0000
commit19309779ac5e2f5a2fd3cbb34421dafb2855ac21 (patch)
tree67dfd3e5d96250325e383183f95b6f5fe1968514 /src/encoding/gob
parent017933163ab6a2b254f0310c61b57db65cded92e (diff)
downloadgo-19309779ac5e2f5a2fd3cbb34421dafb2855ac21.tar.xz
all: gofmt main repo
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/encoding/gob')
-rw-r--r--src/encoding/gob/debug.go27
-rw-r--r--src/encoding/gob/decoder.go2
-rw-r--r--src/encoding/gob/doc.go6
3 files changed, 32 insertions, 3 deletions
diff --git a/src/encoding/gob/debug.go b/src/encoding/gob/debug.go
index c989ab1ad6..dc572fc11e 100644
--- a/src/encoding/gob/debug.go
+++ b/src/encoding/gob/debug.go
@@ -215,6 +215,7 @@ func (deb *debugger) uint64() uint64 {
}
// GobStream:
+//
// DelimitedMessage* (until EOF)
func (deb *debugger) gobStream() {
// Make sure we're single-threaded through here.
@@ -226,6 +227,7 @@ func (deb *debugger) gobStream() {
}
// DelimitedMessage:
+//
// uint(lengthOfMessage) Message
func (deb *debugger) delimitedMessage(indent tab) bool {
for {
@@ -261,12 +263,19 @@ func (deb *debugger) loadBlock(eofOK bool) int {
}
// Message:
+//
// TypeSequence TypedValue
+//
// TypeSequence
+//
// (TypeDefinition DelimitedTypeDefinition*)?
+//
// DelimitedTypeDefinition:
+//
// uint(lengthOfTypeDefinition) TypeDefinition
+//
// TypedValue:
+//
// int(typeId) Value
func (deb *debugger) message(indent tab) bool {
for {
@@ -351,6 +360,7 @@ func (deb *debugger) delta(expect int) int {
}
// TypeDefinition:
+//
// [int(-typeId) (already read)] encodingOfWireType
func (deb *debugger) typeDefinition(indent tab, id typeId) {
deb.dump("type definition for id %d", id)
@@ -437,6 +447,7 @@ func (deb *debugger) typeDefinition(indent tab, id typeId) {
}
// Value:
+//
// SingletonValue | StructValue
func (deb *debugger) value(indent tab, id typeId) {
wire, ok := deb.wireType[id]
@@ -448,6 +459,7 @@ func (deb *debugger) value(indent tab, id typeId) {
}
// SingletonValue:
+//
// uint(0) FieldValue
func (deb *debugger) singletonValue(indent tab, id typeId) {
deb.dump("Singleton value")
@@ -465,6 +477,7 @@ func (deb *debugger) singletonValue(indent tab, id typeId) {
}
// InterfaceValue:
+//
// NilInterfaceValue | NonNilInterfaceValue
func (deb *debugger) interfaceValue(indent tab) {
deb.dump("Start of interface value")
@@ -476,6 +489,7 @@ func (deb *debugger) interfaceValue(indent tab) {
}
// NilInterfaceValue:
+//
// uint(0) [already read]
func (deb *debugger) nilInterfaceValue(indent tab) int {
fmt.Fprintf(os.Stderr, "%snil interface\n", indent)
@@ -483,12 +497,19 @@ func (deb *debugger) nilInterfaceValue(indent tab) int {
}
// NonNilInterfaceValue:
+//
// ConcreteTypeName TypeSequence InterfaceContents
+//
// ConcreteTypeName:
+//
// uint(lengthOfName) [already read=n] name
+//
// InterfaceContents:
+//
// int(concreteTypeId) DelimitedValue
+//
// DelimitedValue:
+//
// uint(length) Value
func (deb *debugger) nonNilInterfaceValue(indent tab, nameLen int) {
// ConcreteTypeName
@@ -549,6 +570,7 @@ func (deb *debugger) printWireType(indent tab, wire *wireType) {
// fieldValue prints a value of any type, such as a struct field.
// FieldValue:
+//
// builtinValue | ArrayValue | MapValue | SliceValue | StructValue | InterfaceValue
func (deb *debugger) fieldValue(indent tab, id typeId) {
_, ok := builtinIdToType[id]
@@ -622,6 +644,7 @@ func (deb *debugger) printBuiltin(indent tab, id typeId) {
}
// ArrayValue:
+//
// uint(n) FieldValue*n
func (deb *debugger) arrayValue(indent tab, wire *wireType) {
elemId := wire.ArrayT.Elem
@@ -636,6 +659,7 @@ func (deb *debugger) arrayValue(indent tab, wire *wireType) {
}
// MapValue:
+//
// uint(n) (FieldValue FieldValue)*n [n (key, value) pairs]
func (deb *debugger) mapValue(indent tab, wire *wireType) {
keyId := wire.MapT.Key
@@ -649,6 +673,7 @@ func (deb *debugger) mapValue(indent tab, wire *wireType) {
}
// SliceValue:
+//
// uint(n) (n FieldValue)
func (deb *debugger) sliceValue(indent tab, wire *wireType) {
elemId := wire.SliceT.Elem
@@ -662,6 +687,7 @@ func (deb *debugger) sliceValue(indent tab, wire *wireType) {
}
// StructValue:
+//
// (uint(fieldDelta) FieldValue)*
func (deb *debugger) structValue(indent tab, id typeId) {
deb.dump("Start of struct value of %q id=%d\n<<\n", id.name(), id)
@@ -692,6 +718,7 @@ func (deb *debugger) structValue(indent tab, id typeId) {
}
// GobEncoderValue:
+//
// uint(n) byte*n
func (deb *debugger) gobEncoderValue(indent tab, id typeId) {
len := deb.uint64()
diff --git a/src/encoding/gob/decoder.go b/src/encoding/gob/decoder.go
index 86f54b4193..9c4257eb3b 100644
--- a/src/encoding/gob/decoder.go
+++ b/src/encoding/gob/decoder.go
@@ -132,7 +132,9 @@ func (dec *Decoder) nextUint() uint64 {
// decodeTypeSequence parses:
// TypeSequence
+//
// (TypeDefinition DelimitedTypeDefinition*)?
+//
// and returns the type id of the next value. It returns -1 at
// EOF. Upon return, the remainder of dec.buf is the value to be
// decoded. If this is an interface value, it can be ignored by
diff --git a/src/encoding/gob/doc.go b/src/encoding/gob/doc.go
index c765707139..306d395d5b 100644
--- a/src/encoding/gob/doc.go
+++ b/src/encoding/gob/doc.go
@@ -12,7 +12,7 @@ The implementation compiles a custom codec for each data type in the stream and
is most efficient when a single Encoder is used to transmit a stream of values,
amortizing the cost of compilation.
-Basics
+# Basics
A stream of gobs is self-describing. Each data item in the stream is preceded by
a specification of its type, expressed in terms of a small set of predefined
@@ -27,7 +27,7 @@ all type information is sent before it is needed. At the receive side, a
Decoder retrieves values from the encoded stream and unpacks them into local
variables.
-Types and Values
+# Types and Values
The source and destination values/types need not correspond exactly. For structs,
fields (identified by name) that are in the source but absent from the receiving
@@ -101,7 +101,7 @@ Gob can decode a value of any type implementing the GobDecoder or
encoding.BinaryUnmarshaler interfaces by calling the corresponding method,
again in that order of preference.
-Encoding Details
+# Encoding Details
This section documents the encoding, details that are not important for most
users. Details are presented bottom-up.