Skip to content

Commit 2241af2

Browse files
committed
Add more URL refs to docs
1 parent 66423be commit 2241af2

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

decoder.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,32 @@ func (t parseState) String() string {
3636

3737
/*
3838
Decoder provides a netstring decode capability. A Decoder *must* be constructed with
39-
NewDecoder() otherwise subsequent calls will panic.
39+
[NewDecoder] otherwise subsequent calls will panic.
4040
41-
The byte-stream from the io.Reader provided to NewDecoder() is expected to contain a pure
42-
stream of netstrings. Each netstring can be retrieved via Decode() and DecodeKeyed() for
43-
standard netstrings and "keyed" netstrings respectively. The sending and receiving
41+
The byte-stream from the [io.Reader] provided to [NewDecoder] is expected to contain a
42+
pure stream of netstrings. Each netstring can be retrieved via [Decode] and [DecodeKeyed]
43+
for standard netstrings and "keyed" netstrings respectively. The sending and receiving
4444
applications must agree on all aspects of how these netstrings are interpreted. Typically
4545
they will agree on a message structure which is either a fixed number of standard
4646
netstrings or a variable number of "keyed" netstrings terminated by an end-of-message
4747
sentinel.
4848
49-
The functions Decode() and DecodeKeyed() are used to accessed each decoded netstring as it
50-
becomes available and Unmarshal() is used to decoded a complete "message" containing a
51-
series of "keyed" netstrings (including an end-of-message sentinel) into a simple struct.
49+
[Decode] and [DecodeKeyed] are used to accessed each decoded netstring as it becomes
50+
available and [Unmarshal] is used to decoded a complete "message" containing a series of
51+
"keyed" netstrings (including an end-of-message sentinel) into a simple struct.
5252
53-
It is often good practice to wrap the input io.Reader in a bufio.Reader as this will
54-
likely improve parsing performance of this package.
53+
It is often good practice to wrap the input [io.Reader] in a [bufio.Reader] as this can
54+
improve parsing performance.
5555
5656
If the Decoder detects a malformed netstring, it stops parsing, returns an error and
5757
effective stops all future parsing for that byte stream because once synchronization is
5858
lost, it can never be recovered.
5959
60-
Decoder passes thru io.EOF from the io.Reader, but only after all bytes have been consumed
61-
in the process of producing netstrings. An application should anticipate io.EOF if the
62-
io.Reader constitutes a network connection of some type. Unlike io.Reader, the EOF error
63-
is *not* returned in the same call which returns a valid netstring or message.
60+
Decoder passes [io.EOF] back to the caller from the [io.Reader], but only after all bytes
61+
have been consumed in the process of producing netstrings. An application should
62+
anticipate [io.EOF] if the [io.Reader] constitutes a network connection of some
63+
type. Unlike [io.Reader], the EOF error is *not* returned in the same call which returns a
64+
valid netstring or message.
6465
*/
6566
type Decoder struct {
6667
rdr io.Reader
@@ -187,7 +188,7 @@ func (dec *Decoder) parse() (good []byte) {
187188
// Once an invalid netstring is detected, the byte stream is considered permanently
188189
// unrecoverable and the same error is returned in perpetuity.
189190
//
190-
// The DecodeKeyed() function is better suited if the application is using "keyed"
191+
// The [DecodeKeyed] function is better suited if the application is using "keyed"
191192
// netstrings.
192193
func (dec *Decoder) Decode() (ns []byte, err error) {
193194
ns = dec.parse()

0 commit comments

Comments
 (0)