Skip to content

Commit c218d1c

Browse files
committed
Cleaning up some
1 parent 0cd41e0 commit c218d1c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pkg/inputs/snmp/util/file.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"io"
88
"io/fs"
9-
"io/ioutil"
109
"net/http"
1110
"net/url"
1211
"os"
@@ -52,7 +51,7 @@ func LoadFile(ctx context.Context, file string) ([]byte, error) {
5251
case "git":
5352
return loadFromGit(ctx, u)
5453
default:
55-
return ioutil.ReadFile(file)
54+
return os.ReadFile(file)
5655
}
5756
}
5857

@@ -73,7 +72,7 @@ func WriteFile(ctx context.Context, file string, payload []byte, perms fs.FileMo
7372
case "git":
7473
return writeToGit(ctx, u, payload, perms)
7574
default:
76-
return ioutil.WriteFile(file, payload, perms)
75+
return os.WriteFile(file, payload, perms)
7776
}
7877
}
7978

@@ -89,7 +88,7 @@ func loadFromHttp(ctx context.Context, file string) ([]byte, error) {
8988
}
9089

9190
defer resp.Body.Close()
92-
body, err := ioutil.ReadAll(resp.Body)
91+
body, err := io.ReadAll(resp.Body)
9392
if err != nil {
9493
return nil, err
9594
}
@@ -108,7 +107,7 @@ func writeToHttp(ctx context.Context, file string, payload []byte) error {
108107
}
109108

110109
defer resp.Body.Close()
111-
_, err = ioutil.ReadAll(resp.Body)
110+
_, err = io.ReadAll(resp.Body)
112111
if err != nil {
113112
return err
114113
}
@@ -166,7 +165,7 @@ func writeToGit(ctx context.Context, url *url.URL, payload []byte, perms fs.File
166165
file := path.Join(dir, filePath)
167166

168167
// Copy new file onto path
169-
err = ioutil.WriteFile(file, payload, perms)
168+
err = os.WriteFile(file, payload, perms)
170169
if err != nil {
171170
return fmt.Errorf("%s, WriteFile %s", err.Error(), file)
172171
}
@@ -257,7 +256,7 @@ func gitClone(ctx context.Context, url *url.URL, dir string, branch plumbing.Ref
257256
}
258257
r, err := git.PlainCloneContext(ctx, dir, cloneOpts)
259258
if err != nil {
260-
return "", nil, err
259+
return "", nil, fmt.Errorf("failed to clone git repository %s: %w", gitRepo, err)
261260
}
262261

263262
return filePath, r, err
@@ -280,7 +279,7 @@ func loadFromGit(ctx context.Context, url *url.URL) ([]byte, error) {
280279
}
281280

282281
file := path.Join(dir, filePath)
283-
return ioutil.ReadFile(file)
282+
return os.ReadFile(file)
284283
}
285284

286285
type s3ClientDown interface {

0 commit comments

Comments
 (0)