diff --git a/dockertest.go b/dockertest.go index 54cdcd70..86d07e1b 100644 --- a/dockertest.go +++ b/dockertest.go @@ -6,7 +6,6 @@ package dockertest import ( "fmt" "io" - "io/ioutil" "net" "os" "path/filepath" @@ -340,7 +339,7 @@ func (d *Pool) BuildAndRunWithBuildOptions(buildOpts *BuildOptions, runOpts *Run err := d.Client.BuildImage(dc.BuildImageOptions{ Name: runOpts.Name, Dockerfile: buildOpts.Dockerfile, - OutputStream: ioutil.Discard, + OutputStream: io.Discard, ContextDir: buildOpts.ContextDir, BuildArgs: buildOpts.BuildArgs, Platform: buildOpts.Platform, diff --git a/dockertest_test.go b/dockertest_test.go index eb7647ae..254ba3ae 100644 --- a/dockertest_test.go +++ b/dockertest_test.go @@ -7,7 +7,6 @@ import ( "bytes" "database/sql" "fmt" - "io/ioutil" "log" "net/http" "os" @@ -199,11 +198,10 @@ func TestContainerWithPortBinding(t *testing.T) { func TestBuildImage(t *testing.T) { // Create Dockerfile in temp dir - dir, _ := ioutil.TempDir("", "dockertest") - defer os.RemoveAll(dir) + dir := t.TempDir() dockerfilePath := dir + "/Dockerfile" - ioutil.WriteFile(dockerfilePath, + os.WriteFile(dockerfilePath, []byte("FROM postgres:9.5"), 0o644, ) @@ -217,11 +215,10 @@ func TestBuildImage(t *testing.T) { func TestBuildImageWithBuildArg(t *testing.T) { // Create Dockerfile in temp dir - dir, _ := ioutil.TempDir("", "dockertest") - defer os.RemoveAll(dir) + dir := t.TempDir() dockerfilePath := dir + "/Dockerfile" - ioutil.WriteFile(dockerfilePath, + os.WriteFile(dockerfilePath, []byte((`FROM busybox ARG foo RUN echo -n $foo > /build-time-value diff --git a/examples/FakeGoogleCloudStorage.md b/examples/FakeGoogleCloudStorage.md index 6e0bbe29..54dda1ed 100644 --- a/examples/FakeGoogleCloudStorage.md +++ b/examples/FakeGoogleCloudStorage.md @@ -18,7 +18,7 @@ package main import ( "context" "fmt" - "io/ioutil" + "io" "net/http" "os" "strings" @@ -198,7 +198,7 @@ func readFile(client *storage.Client, bucketName, fileName string) ([]byte, erro return nil, err } defer reader.Close() - return ioutil.ReadAll(reader) + return io.ReadAll(reader) } func deleteFile(client *storage.Client, bucketName, fileName string) error {