aboutsummaryrefslogtreecommitdiff
path: root/src/image
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-10-16 00:49:02 -0400
committerRuss Cox <rsc@golang.org>2020-10-20 18:41:18 +0000
commit1b09d430678d4a6f73b2443463d11f75851aba8a (patch)
treefec040abfc6e1d897f8dcdbb856e77d5bccbb2ca /src/image
parentcb0a0f52e67f128c6ad69027c9a8c7a5caf58446 (diff)
downloadgo-1b09d430678d4a6f73b2443463d11f75851aba8a.tar.gz
go-1b09d430678d4a6f73b2443463d11f75851aba8a.zip
all: update references to symbols moved from io/ioutil to io
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/image')
-rw-r--r--src/image/gif/writer_test.go22
-rw-r--r--src/image/jpeg/writer_test.go6
-rw-r--r--src/image/png/writer_test.go17
3 files changed, 22 insertions, 23 deletions
diff --git a/src/image/gif/writer_test.go b/src/image/gif/writer_test.go
index 1e622b3674..af0105c6be 100644
--- a/src/image/gif/writer_test.go
+++ b/src/image/gif/writer_test.go
@@ -11,7 +11,7 @@ import (
"image/color/palette"
"image/draw"
_ "image/png"
- "io/ioutil"
+ "io"
"math/rand"
"os"
"reflect"
@@ -285,7 +285,7 @@ func TestEncodeMismatchDelay(t *testing.T) {
Image: images,
Delay: make([]int, 1),
}
- if err := EncodeAll(ioutil.Discard, g0); err == nil {
+ if err := EncodeAll(io.Discard, g0); err == nil {
t.Error("expected error from mismatched delay and image slice lengths")
}
@@ -297,13 +297,13 @@ func TestEncodeMismatchDelay(t *testing.T) {
for i := range g1.Disposal {
g1.Disposal[i] = DisposalNone
}
- if err := EncodeAll(ioutil.Discard, g1); err == nil {
+ if err := EncodeAll(io.Discard, g1); err == nil {
t.Error("expected error from mismatched disposal and image slice lengths")
}
}
func TestEncodeZeroGIF(t *testing.T) {
- if err := EncodeAll(ioutil.Discard, &GIF{}); err == nil {
+ if err := EncodeAll(io.Discard, &GIF{}); err == nil {
t.Error("expected error from providing empty gif")
}
}
@@ -324,7 +324,7 @@ func TestEncodeAllFramesOutOfBounds(t *testing.T) {
Height: upperBound,
},
}
- err := EncodeAll(ioutil.Discard, g)
+ err := EncodeAll(io.Discard, g)
if upperBound >= 8 {
if err != nil {
t.Errorf("upperBound=%d: %v", upperBound, err)
@@ -430,7 +430,7 @@ func TestEncodeImplicitConfigSize(t *testing.T) {
Image: images,
Delay: make([]int, len(images)),
}
- err := EncodeAll(ioutil.Discard, g)
+ err := EncodeAll(io.Discard, g)
if lowerBound >= 0 {
if err != nil {
t.Errorf("lowerBound=%d: %v", lowerBound, err)
@@ -509,7 +509,7 @@ func TestEncodeBadPalettes(t *testing.T) {
}
}
- err := EncodeAll(ioutil.Discard, &GIF{
+ err := EncodeAll(io.Discard, &GIF{
Image: []*image.Paletted{
image.NewPaletted(image.Rect(0, 0, w, h), pal),
},
@@ -668,7 +668,7 @@ func BenchmarkEncodeRandomPaletted(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, paletted, nil)
+ Encode(io.Discard, paletted, nil)
}
}
@@ -691,7 +691,7 @@ func BenchmarkEncodeRandomRGBA(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, rgba, nil)
+ Encode(io.Discard, rgba, nil)
}
}
@@ -708,7 +708,7 @@ func BenchmarkEncodeRealisticPaletted(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, paletted, nil)
+ Encode(io.Discard, paletted, nil)
}
}
@@ -729,6 +729,6 @@ func BenchmarkEncodeRealisticRGBA(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, rgba, nil)
+ Encode(io.Discard, rgba, nil)
}
}
diff --git a/src/image/jpeg/writer_test.go b/src/image/jpeg/writer_test.go
index 3aff742632..abd5e32333 100644
--- a/src/image/jpeg/writer_test.go
+++ b/src/image/jpeg/writer_test.go
@@ -10,7 +10,7 @@ import (
"image"
"image/color"
"image/png"
- "io/ioutil"
+ "io"
"math/rand"
"os"
"testing"
@@ -261,7 +261,7 @@ func BenchmarkEncodeRGBA(b *testing.B) {
b.ResetTimer()
options := &Options{Quality: 90}
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, img, options)
+ Encode(io.Discard, img, options)
}
}
@@ -283,6 +283,6 @@ func BenchmarkEncodeYCbCr(b *testing.B) {
b.ResetTimer()
options := &Options{Quality: 90}
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, img, options)
+ Encode(io.Discard, img, options)
}
}
diff --git a/src/image/png/writer_test.go b/src/image/png/writer_test.go
index 5d131ff823..47aa861339 100644
--- a/src/image/png/writer_test.go
+++ b/src/image/png/writer_test.go
@@ -12,7 +12,6 @@ import (
"image"
"image/color"
"io"
- "io/ioutil"
"testing"
)
@@ -169,7 +168,7 @@ func TestWriterPaletted(t *testing.T) {
t.Error(err)
return
}
- n, err := io.Copy(ioutil.Discard, r)
+ n, err := io.Copy(io.Discard, r)
if err != nil {
t.Errorf("got error while reading image data: %v", err)
}
@@ -234,7 +233,7 @@ func BenchmarkEncodeGray(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, img)
+ Encode(io.Discard, img)
}
}
@@ -259,7 +258,7 @@ func BenchmarkEncodeGrayWithBufferPool(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- e.Encode(ioutil.Discard, img)
+ e.Encode(io.Discard, img)
}
}
@@ -279,7 +278,7 @@ func BenchmarkEncodeNRGBOpaque(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, img)
+ Encode(io.Discard, img)
}
}
@@ -292,7 +291,7 @@ func BenchmarkEncodeNRGBA(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, img)
+ Encode(io.Discard, img)
}
}
@@ -305,7 +304,7 @@ func BenchmarkEncodePaletted(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, img)
+ Encode(io.Discard, img)
}
}
@@ -325,7 +324,7 @@ func BenchmarkEncodeRGBOpaque(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, img)
+ Encode(io.Discard, img)
}
}
@@ -338,6 +337,6 @@ func BenchmarkEncodeRGBA(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
- Encode(ioutil.Discard, img)
+ Encode(io.Discard, img)
}
}