Skip to content

Commit a547c5e

Browse files
authored
Merge pull request #29 from bitnami/go-1.18.2
Update go and deps versions
2 parents 0080879 + cd3be91 commit a547c5e

File tree

13 files changed

+58
-47
lines changed

13 files changed

+58
-47
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: CI
22

33
# Controls when the action will run.
44
on:
5-
# Triggers the workflow on push or pull request events but only for the master branch
5+
# Triggers the workflow on push or pull request events but only for the main branch
66
push:
77
branches:
8-
- master
8+
- main
99

1010
release:
1111
types: [published]
@@ -27,7 +27,7 @@ jobs:
2727
- uses: actions/checkout@v2
2828
- uses: actions/setup-go@v2
2929
with:
30-
go-version: '^1.18.2' # The Go version to download (if necessary) and use.
30+
go-version: '^1.18.8' # The Go version to download (if necessary) and use.
3131
- name: Install Build Dependencies
3232
run: make get-build-deps
3333
- name: Download required modules

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ go 1.18
55
require (
66
github.com/VividCortex/godaemon v1.0.0
77
github.com/julienschmidt/httprouter v1.3.0
8-
github.com/sirupsen/logrus v1.8.1
9-
github.com/spf13/cobra v1.2.1
10-
github.com/stretchr/testify v1.7.0
11-
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359
8+
github.com/sirupsen/logrus v1.9.0
9+
github.com/spf13/cobra v1.6.1
10+
github.com/stretchr/testify v1.8.1
11+
golang.org/x/sys v0.2.0
1212
)
1313

1414
require (
1515
github.com/davecgh/go-spew v1.1.1 // indirect
16-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
16+
github.com/inconshreveable/mousetrap v1.0.1 // indirect
1717
github.com/pmezard/go-difflib v1.0.0 // indirect
1818
github.com/spf13/pflag v1.0.5 // indirect
19-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
19+
gopkg.in/yaml.v3 v3.0.1 // indirect
2020
)

go.sum

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnht
5858
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
5959
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
6060
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
61+
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
6162
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6263
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
6364
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -163,6 +164,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
163164
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
164165
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
165166
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
167+
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
168+
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
166169
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
167170
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
168171
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
@@ -203,29 +206,40 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
203206
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
204207
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
205208
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
209+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
206210
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
207211
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
208212
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
209213
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
210214
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
215+
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
216+
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
211217
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
212218
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
213219
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
214220
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
215221
github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
216222
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
223+
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
224+
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
217225
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
218226
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
219227
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
220228
github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns=
221229
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
230+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
231+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
222232
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
223233
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
224234
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
225235
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
226236
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
227237
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
228238
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
239+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
240+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
241+
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
242+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
229243
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
230244
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
231245
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -390,6 +404,9 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w
390404
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
391405
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik=
392406
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
407+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
408+
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
409+
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
393410
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
394411
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
395412
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -558,6 +575,7 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
558575
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
559576
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
560577
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
578+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
561579
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
562580
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
563581
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -570,6 +588,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
570588
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
571589
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
572590
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
591+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
592+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
573593
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
574594
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
575595
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

gonit_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bytes"
55
"flag"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"os/exec"
109
"path/filepath"
@@ -520,7 +519,7 @@ func (suite *CmdSuite) TestReloadCommand() {
520519
suite.NotRegexp("(?s).*Process mysql.*", r.stdout)
521520

522521
suite.NotRegexp("(?s).*Process sample_check.*", r.stdout)
523-
ioutil.WriteFile(
522+
os.WriteFile(
524523
filepath.Join(rootDir, "conf/gonit/conf.d/mysql.conf"),
525524
[]byte("check process sample_check"), os.FileMode(0644))
526525

gonittest/utils.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"html/template"
77
"io"
8-
"io/ioutil"
98
"os"
109
"path/filepath"
1110
"reflect"
@@ -44,7 +43,7 @@ type tmplResolver struct {
4443

4544
func (r *tmplResolver) LoadFile(path string) error {
4645
if r.Error == nil {
47-
data, err := ioutil.ReadFile(path)
46+
data, err := os.ReadFile(path)
4847
r.Data, r.Error = string(data), err
4948
}
5049
return r.Error
@@ -56,7 +55,7 @@ func (r *tmplResolver) Load(data string) {
5655

5756
func (r *tmplResolver) WriteToFile(path string) error {
5857
if r.Error == nil {
59-
r.Error = ioutil.WriteFile(path, []byte(r.Data), os.FileMode(0755))
58+
r.Error = os.WriteFile(path, []byte(r.Data), os.FileMode(0755))
6059
}
6160
return r.Error
6261
}

log/log.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package log
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76
"os"
87
"path/filepath"
98
"strings"
@@ -48,7 +47,7 @@ func New() *logrus.Logger {
4847

4948
// DummyLogger provides a dummy logger object
5049
func DummyLogger() *Logger {
51-
return StreamLogger(ioutil.Discard)
50+
return StreamLogger(io.Discard)
5251
}
5352

5453
// StreamLogger returns a logger backed by a provided io.Writter

monitor/parsing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package monitor
22

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"os"
66
"path/filepath"
77
"regexp"
88
"strings"
@@ -80,7 +80,7 @@ func (cp *configParser) ParseConfigFile(f string, cw interface {
8080
// TODO: Not sure if bug or feature, but monit only validates the first level
8181
// config file. Included files permissions and ownership are not validated
8282
// data, err := utils.ReadSecure(f)
83-
bytes, err := ioutil.ReadFile(utils.AbsFile(f))
83+
bytes, err := os.ReadFile(utils.AbsFile(f))
8484
if err != nil {
8585
return err
8686
}

testutils/sandbox.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package testutils
22

33
import (
4-
"io/ioutil"
54
"log"
65
"math/rand"
76
"os"
@@ -33,7 +32,7 @@ func NewSandbox(args ...string) *Sandbox {
3332
if len(args) > 0 {
3433
root = args[0]
3534
} else {
36-
root, err = ioutil.TempDir("", "sandbox")
35+
root, err = os.MkdirTemp("", "sandbox")
3736
if err != nil {
3837
log.Fatal("Error creating temporary directory for sandbox")
3938
}
@@ -117,7 +116,7 @@ func (sb *Sandbox) Write(path string, data string) (string, error) {
117116
func (sb *Sandbox) WriteFile(path string, data []byte, mode os.FileMode) (string, error) {
118117
f := sb.Normalize(path)
119118
sb.Track(f)
120-
return f, ioutil.WriteFile(f, data, mode)
119+
return f, os.WriteFile(f, data, mode)
121120
}
122121

123122
// Cleanup removes all the resources created by the sandbox

testutils/sandbox_test.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package testutils
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87
"regexp"
@@ -14,7 +13,7 @@ import (
1413
)
1514

1615
func TestNewSandbox(t *testing.T) {
17-
root, err := ioutil.TempDir("", "sandbox")
16+
root, err := os.MkdirTemp("", "sandbox")
1817
require.NoError(t, err)
1918

2019
sb1 := NewSandbox(root)
@@ -45,7 +44,7 @@ func TestCleanup(t *testing.T) {
4544
defer sb.Cleanup()
4645

4746
tmpFile := filepath.Join(sb.Root, "sample.txt")
48-
err := ioutil.WriteFile(tmpFile, []byte{}, os.FileMode(0644))
47+
err := os.WriteFile(tmpFile, []byte{}, os.FileMode(0644))
4948
require.NoError(t, err)
5049

5150
assert.NoError(t, sb.Cleanup())
@@ -72,7 +71,7 @@ func TestCleanup(t *testing.T) {
7271
}
7372

7473
func TestNormalize(t *testing.T) {
75-
root, err := ioutil.TempDir("", "sandbox")
74+
root, err := os.MkdirTemp("", "sandbox")
7675
require.NoError(t, err)
7776

7877
sb := NewSandbox(root)
@@ -87,7 +86,7 @@ func TestNormalize(t *testing.T) {
8786

8887
func TestContainsPath(t *testing.T) {
8988

90-
root, err := ioutil.TempDir("", "sandbox")
89+
root, err := os.MkdirTemp("", "sandbox")
9190
require.NoError(t, err)
9291

9392
sb := NewSandbox(root)
@@ -111,7 +110,7 @@ func TestContainsPath(t *testing.T) {
111110
}
112111

113112
func TestWriteFile(t *testing.T) {
114-
root, err := ioutil.TempDir("", "sandbox")
113+
root, err := os.MkdirTemp("", "sandbox")
115114
require.NoError(t, err)
116115

117116
sb := NewSandbox(root)
@@ -122,15 +121,15 @@ func TestWriteFile(t *testing.T) {
122121
f, err := sb.WriteFile(tail, []byte(data), os.FileMode(0644))
123122
assert.NoError(t, err)
124123
assert.Equal(t, filepath.Join(root, tail), f)
125-
read, err := ioutil.ReadFile(f)
124+
read, err := os.ReadFile(f)
126125
assert.NoError(t, err)
127126

128127
assert.Equal(t, data, string(read))
129128
}
130129

131130
func TestWrite(t *testing.T) {
132131

133-
root, err := ioutil.TempDir("", "sandbox")
132+
root, err := os.MkdirTemp("", "sandbox")
134133
require.NoError(t, err)
135134

136135
sb := NewSandbox(root)
@@ -141,14 +140,14 @@ func TestWrite(t *testing.T) {
141140
f, err := sb.Write(tail, data)
142141
assert.NoError(t, err)
143142
assert.Equal(t, filepath.Join(root, tail), f)
144-
read, err := ioutil.ReadFile(f)
143+
read, err := os.ReadFile(f)
145144
assert.NoError(t, err)
146145

147146
assert.Equal(t, data, string(read))
148147
}
149148

150149
func TestSymlink(t *testing.T) {
151-
root, err := ioutil.TempDir("", "sandbox")
150+
root, err := os.MkdirTemp("", "sandbox")
152151
require.NoError(t, err)
153152

154153
sb := NewSandbox(root)
@@ -162,7 +161,7 @@ func TestSymlink(t *testing.T) {
162161
}
163162

164163
func TestMkdir(t *testing.T) {
165-
root, err := ioutil.TempDir("", "sandbox")
164+
root, err := os.MkdirTemp("", "sandbox")
166165
require.NoError(t, err)
167166

168167
sb := NewSandbox(root)
@@ -180,7 +179,7 @@ func TestMkdir(t *testing.T) {
180179
assert.True(t, s.IsDir(), "Expected %s to be a directory", fullPath)
181180
}
182181
func TestTouch(t *testing.T) {
183-
root, err := ioutil.TempDir("", "sandbox")
182+
root, err := os.MkdirTemp("", "sandbox")
184183
require.NoError(t, err)
185184

186185
sb := NewSandbox(root)
@@ -205,7 +204,7 @@ func TestTouch(t *testing.T) {
205204
}
206205

207206
func TestTempFile(t *testing.T) {
208-
root, err := ioutil.TempDir("", "sandbox")
207+
root, err := os.MkdirTemp("", "sandbox")
209208
require.NoError(t, err)
210209

211210
sb := NewSandbox(root)
@@ -226,7 +225,7 @@ func TestTempFile(t *testing.T) {
226225
// If the file to create exists, an additional numeric index is appended until
227226
// the target file does not exists
228227
currentIndex := tempFileIndex
229-
ioutil.WriteFile(
228+
os.WriteFile(
230229
filepath.Join(root, fmt.Sprintf("%s%d", tail, currentIndex)),
231230
[]byte{}, os.FileMode(0644),
232231
)
@@ -235,12 +234,12 @@ func TestTempFile(t *testing.T) {
235234
assert.Equal(t, fmt.Sprintf("%s/%s%d0", root, tail, currentIndex), f3)
236235

237236
currentIndex = tempFileIndex
238-
ioutil.WriteFile(
237+
os.WriteFile(
239238
filepath.Join(root, fmt.Sprintf("%s%d", tail, currentIndex)),
240239
[]byte{}, os.FileMode(0644),
241240
)
242241
for i := 0; i < 2; i++ {
243-
ioutil.WriteFile(
242+
os.WriteFile(
244243
filepath.Join(root, fmt.Sprintf("%s%d%d", tail, currentIndex, i)),
245244
[]byte{}, os.FileMode(0644),
246245
)

0 commit comments

Comments
 (0)