@@ -21,7 +21,12 @@ and vice versa,
2121but their counterparts for binary formats
2222are sorely missing from the package ` encoding/binary ` .
2323
24- ### Message Formats
24+ ### Binary Formats
25+ Message and file formats specify how bits are arranged to encode information.
26+ Control over individual bits or groups smaller than a byte is often required
27+ to put together and take apart these binary structures.
28+
29+ #### Message Formats
2530Messages are the lifeblood of network applications.
2631The following specifications
2732quoted from [ Section 3.1] ( https://datatracker.ietf.org/doc/html/rfc791#section-3.1 )
@@ -58,6 +63,13 @@ at the beginning of every internet datagram (more fondly known as a "packet").
5863 Note that each tick mark represents one bit position.
5964```
6065
66+ It is highly unlikely that a developer
67+ would ever need to implement these protocols
68+ (since in Go, the package [ ` net ` ] ( https://pkg.go.dev/net )
69+ supplies types and methods that abstract away low-level details),
70+ but they makes an appropriate illustration of binary message formats.
71+
72+
6173```
6274 TCP Header Format
6375
@@ -89,7 +101,7 @@ at the beginning of every internet datagram (more fondly known as a "packet").
89101 Figure 3.
90102```
91103
92- ### File Formats
104+ #### File Formats
93105Binary file formats are not significantly different from message formats
94106from an application developer's perspective.
95107[ RFC 1952] ( https://datatracker.ietf.org/doc/html/rfc1952 )
@@ -149,9 +161,10 @@ offers a gentle introduction to the topic.
149161 bit 7 reserved
150162```
151163
152- Message and file formats specify how bits are arranged to encode information.
153- Control over individual bits or groups smaller than a byte is often required
154- to put together and take apart these binary structures.
164+ Package [ ` compress/gzip ` ] ( https://pkg.go.dev/compress/gzip )
165+ in the Go standard library spares developers the need to (de)serialise
166+ or even to understand the GZIP file format,
167+ but the example is included here as a stand-in for other, custom formats.
155168
156169## Working with Binary Formats in Go
157170The smallest data structures Go provides are
@@ -238,12 +251,6 @@ type RFC791InternetHeaderFormatWithoutOptions struct {
238251```
239252
240253### Example
241- It is highly unlikely that a developer
242- would ever need to implement the Internet Protocol
243- (since in Go, the package [ ` net ` ] ( https://pkg.go.dev/net )
244- supplies types and methods that abstract away low-level details),
245- but it makes an appropriate illustration of binary message formats.
246-
247254``` go
248255package main
249256
0 commit comments