diff options
| author | Daniel Martà <mvdan@mvdan.cc> | 2017-11-19 13:40:05 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2017-11-19 16:37:43 +0000 |
| commit | f91ab6c0256877841944c57a12bd779edb2a0f66 (patch) | |
| tree | 5f64893df653e2e294af94fa341ddbd19e5a80cb /src/bytes/buffer.go | |
| parent | e4a3043d1d8691bb1fc39a8542e378f713de7aa0 (diff) | |
| download | go-f91ab6c0256877841944c57a12bd779edb2a0f66.tar.xz | |
bytes: don't use an iota for the readOp constants
As per the comments in golang.org/cl/78617. Also leaving a comment here,
to make sure noone else thinks to re-introduce the iota like I did.
Change-Id: I2a2275998b81896eaa0e9d5ee0197661ebe84acf
Reviewed-on: https://go-review.googlesource.com/78676
Run-TryBot: Daniel Martà <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/bytes/buffer.go')
| -rw-r--r-- | src/bytes/buffer.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/bytes/buffer.go b/src/bytes/buffer.go index 83bb1c7eb5..67771846fc 100644 --- a/src/bytes/buffer.go +++ b/src/bytes/buffer.go @@ -30,13 +30,15 @@ type Buffer struct { // converted to int they correspond to the rune size that was read. type readOp int8 +// Don't use iota for these, as the values need to correspond with the +// names and comments, which is easier to see when being explicit. const ( - opRead readOp = iota - 1 // Any other read operation. - opInvalid // Non-read operation. - opReadRune1 // Read rune of size 1. - opReadRune2 // Read rune of size 2. - opReadRune3 // Read rune of size 3. - opReadRune4 // Read rune of size 4. + opRead readOp = -1 // Any other read operation. + opInvalid readOp = 0 // Non-read operation. + opReadRune1 readOp = 1 // Read rune of size 1. + opReadRune2 readOp = 2 // Read rune of size 2. + opReadRune3 readOp = 3 // Read rune of size 3. + opReadRune4 readOp = 4 // Read rune of size 4. ) // ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer. |
