Skip to content

Commit 243b041

Browse files
committed
Replace deprecated io/ioutil with modern os/io equivalents
Replaces ioutil.ReadFile, TempDir and ReadDir calls with their Go 1.16+ replacements in os package. Removes the io/ioutil import from all affected files.
1 parent 832aa72 commit 243b041

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

fixtures/util/dynatrace/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
76
"log"
87
"net/http"
98
"os"
@@ -69,7 +68,7 @@ func main() {
6968
json.NewEncoder(w).Encode(payload)
7069

7170
case "/v1/deployment/installer/agent/processmoduleconfig":
72-
fakeConfig, err := ioutil.ReadFile("fake_config.json")
71+
fakeConfig, err := os.ReadFile("fake_config.json")
7372
if err != nil {
7473
w.WriteHeader(http.StatusInternalServerError)
7574
w.Write([]byte(err.Error()))

src/php/extensions/composer/composer.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"fmt"
66
"io"
7-
"io/ioutil"
87
"net/http"
98
"os"
109
"os/exec"
@@ -650,7 +649,7 @@ func (e *ComposerExtension) installComposer(ctx *extensions.Context, installer *
650649
fmt.Printf("-----> Installing composer %s\n", composerVersion)
651650

652651
// Create a temporary directory for the composer download
653-
tmpDir, err := ioutil.TempDir("", "composer-install")
652+
tmpDir, err := os.MkdirTemp("", "composer-install")
654653
if err != nil {
655654
return fmt.Errorf("failed to create temp dir: %w", err)
656655
}
@@ -666,7 +665,7 @@ func (e *ComposerExtension) installComposer(ctx *extensions.Context, installer *
666665
}
667666

668667
// Find the downloaded .phar file (e.g., composer_2.8.8_linux_noarch_cflinuxfs4_abc123.phar)
669-
files, err := ioutil.ReadDir(tmpDir)
668+
files, err := os.ReadDir(tmpDir)
670669
if err != nil {
671670
return fmt.Errorf("failed to read temp dir: %w", err)
672671
}

0 commit comments

Comments
 (0)