diff options
| author | nlwkobe30 <nlwkobe30@gmail.com> | 2024-08-30 19:05:07 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-09-03 20:55:15 +0000 |
| commit | 7cd0a4be5cdbb84142ec330daba6087eece48341 (patch) | |
| tree | 498439f59e7cf228c9427c540bccdc7c2930fe7c /src/bytes | |
| parent | b8e533a7cdc60d84a0c52bfaf3dcb5bf148ac3a8 (diff) | |
| download | go-7cd0a4be5cdbb84142ec330daba6087eece48341.tar.xz | |
all: omit unnecessary 0 in slice expression
All changes are related to the code, except for the comments in src/regexp/syntax/parse.go and src/slices/slices.go.
Change-Id: I73c5d3c54099749b62210aa7f3182c5eb84bb6a6
GitHub-Last-Rev: 794aa9b0539811d00e1cd42be1e8d9fe9afe0281
GitHub-Pull-Request: golang/go#69170
Reviewed-on: https://go-review.googlesource.com/c/go/+/609678
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/bytes')
| -rw-r--r-- | src/bytes/buffer_test.go | 8 | ||||
| -rw-r--r-- | src/bytes/bytes.go | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/bytes/buffer_test.go b/src/bytes/buffer_test.go index 3c964fc6b9..97fca5a9d1 100644 --- a/src/bytes/buffer_test.go +++ b/src/bytes/buffer_test.go @@ -213,7 +213,7 @@ func TestLargeByteWrites(t *testing.T) { func TestLargeStringReads(t *testing.T) { var buf Buffer for i := 3; i < 30; i += 3 { - s := fillString(t, "TestLargeReads (1)", &buf, "", 5, testString[0:len(testString)/i]) + s := fillString(t, "TestLargeReads (1)", &buf, "", 5, testString[:len(testString)/i]) empty(t, "TestLargeReads (2)", &buf, s, make([]byte, len(testString))) } check(t, "TestLargeStringReads (3)", &buf, "") @@ -222,7 +222,7 @@ func TestLargeStringReads(t *testing.T) { func TestLargeByteReads(t *testing.T) { var buf Buffer for i := 3; i < 30; i += 3 { - s := fillBytes(t, "TestLargeReads (1)", &buf, "", 5, testBytes[0:len(testBytes)/i]) + s := fillBytes(t, "TestLargeReads (1)", &buf, "", 5, testBytes[:len(testBytes)/i]) empty(t, "TestLargeReads (2)", &buf, s, make([]byte, len(testString))) } check(t, "TestLargeByteReads (3)", &buf, "") @@ -274,7 +274,7 @@ func TestNil(t *testing.T) { func TestReadFrom(t *testing.T) { var buf Buffer for i := 3; i < 30; i += 3 { - s := fillBytes(t, "TestReadFrom (1)", &buf, "", 5, testBytes[0:len(testBytes)/i]) + s := fillBytes(t, "TestReadFrom (1)", &buf, "", 5, testBytes[:len(testBytes)/i]) var b Buffer b.ReadFrom(&buf) empty(t, "TestReadFrom (2)", &b, s, make([]byte, len(testString))) @@ -337,7 +337,7 @@ func TestReadFromNegativeReader(t *testing.T) { func TestWriteTo(t *testing.T) { var buf Buffer for i := 3; i < 30; i += 3 { - s := fillBytes(t, "TestWriteTo (1)", &buf, "", 5, testBytes[0:len(testBytes)/i]) + s := fillBytes(t, "TestWriteTo (1)", &buf, "", 5, testBytes[:len(testBytes)/i]) var b Buffer buf.WriteTo(&b) empty(t, "TestWriteTo (2)", &b, s, make([]byte, len(testString))) diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index bdb0366897..4a2c9eac57 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -592,7 +592,7 @@ func Join(s [][]byte, sep []byte) []byte { // HasPrefix reports whether the byte slice s begins with prefix. func HasPrefix(s, prefix []byte) bool { - return len(s) >= len(prefix) && Equal(s[0:len(prefix)], prefix) + return len(s) >= len(prefix) && Equal(s[:len(prefix)], prefix) } // HasSuffix reports whether the byte slice s ends with suffix. |
