From b396ed0ca043ee9abf5d4b958272b69ff9456a22 Mon Sep 17 00:00:00 2001 From: Guillem Bonet Date: Wed, 15 Nov 2023 09:30:46 +0100 Subject: [PATCH] bump more dependencies and get rid of ioutil Signed-off-by: Guillem Bonet --- ci/deb/tempate.go | 4 +- ci/packages/raspberry.go | 5 +-- ci/release/github.go | 4 +- cmd/commands/cli/command_identities.go | 3 +- cmd/commands/cli/command_orders.go | 4 +- cmd/commands/reset/command_test.go | 3 +- config/config_test.go | 7 ++- consumer/session/session_storage_test.go | 3 +- core/auth/jwt.go | 8 ++-- core/beneficiary/saver_test.go | 3 +- .../discovery/proposal/filter_presets_test.go | 3 +- core/ip/fallbacks.go | 4 +- core/location/gendb/loader.go | 4 +- core/location/generator/generator.go | 3 +- core/quality/elastic_search_transport.go | 4 +- core/quality/morqa_transport_test.go | 4 +- core/quality/mysterium_morqa.go | 4 +- core/storage/boltdb/boltdbtest/db.go | 5 +-- go.mod | 18 ++++---- go.sum | 43 ++++++++++--------- identity/cache.go | 5 +-- identity/keystore_filesystem.go | 4 +- identity/registry/storage_test.go | 3 +- identity/resident_country_test.go | 3 +- logconfig/collector.go | 16 ++++--- logconfig/collector_test.go | 5 +-- logconfig/rollingwriter/rollingwriter.go | 10 +++-- pilvytis/api.go | 4 +- .../pingpong/hermes_promise_storage_test.go | 5 +-- session/pingpong/invoice_payer_test.go | 7 ++- session/pingpong/invoice_storage_test.go | 3 +- session/pingpong/invoice_tracker_test.go | 19 ++++---- .../settlement_history_storage_test.go | 3 +- supervisor/config/config.go | 4 +- tequilapi/client/http_client.go | 3 +- tequilapi/endpoints/assets/docs.go | 3 +- tequilapi/endpoints/validation_test.go | 3 +- tequilapi/launchpad/api_test.go | 4 +- ui/server_test.go | 3 +- ui/versionmanager/version_config.go | 5 +-- ui/versionmanager/version_manager.go | 3 +- ui/versionmanager/version_manager_test.go | 9 ++-- utils/fileutil/fileutil.go | 5 +-- 43 files changed, 124 insertions(+), 141 deletions(-) diff --git a/ci/deb/tempate.go b/ci/deb/tempate.go index 21b1ebc96f..4a8a9e78ff 100644 --- a/ci/deb/tempate.go +++ b/ci/deb/tempate.go @@ -19,7 +19,7 @@ package deb import ( "fmt" - "io/ioutil" + "io" "net/http" "os" "strings" @@ -51,7 +51,7 @@ func TermsTemplateFile(path string) error { defer resp.Body.Close() - terms, err := ioutil.ReadAll(resp.Body) + terms, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/ci/packages/raspberry.go b/ci/packages/raspberry.go index fa6a48268b..ddec57dea3 100644 --- a/ci/packages/raspberry.go +++ b/ci/packages/raspberry.go @@ -19,14 +19,13 @@ package packages import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3/types" - "github.com/mholt/archiver" + "github.com/mholt/archiver/v3" "github.com/mysteriumnetwork/go-ci/env" "github.com/mysteriumnetwork/go-ci/job" "github.com/mysteriumnetwork/go-ci/shell" @@ -192,7 +191,7 @@ func fetchRaspbianImage() (filename string, err error) { return "", err } - extractedFiles, err := ioutil.ReadDir(localRaspbianImgDir) + extractedFiles, err := os.ReadDir(localRaspbianImgDir) if err != nil { return "", err } diff --git a/ci/release/github.go b/ci/release/github.go index d612c0a592..4c2deb5365 100644 --- a/ci/release/github.go +++ b/ci/release/github.go @@ -19,7 +19,7 @@ package release import ( "fmt" - "io/ioutil" + "os" "path" "time" @@ -53,7 +53,7 @@ func releaseGithub(opts *releaseGithubOpts) error { return err } - artifactFilenames, err := ioutil.ReadDir("build/package") + artifactFilenames, err := os.ReadDir("build/package") if err != nil { return err } diff --git a/cmd/commands/cli/command_identities.go b/cmd/commands/cli/command_identities.go index 3c31ec36ae..ba827d1834 100644 --- a/cmd/commands/cli/command_identities.go +++ b/cmd/commands/cli/command_identities.go @@ -20,7 +20,6 @@ package cli import ( "errors" "fmt" - "io/ioutil" "math/big" "os" "strconv" @@ -554,7 +553,7 @@ func (c *cliApp) importIdentity(actionsArgs []string) (err error) { blob := []byte(key) if _, err := os.Stat(key); err == nil { - blob, err = ioutil.ReadFile(key) + blob, err = os.ReadFile(key) if err != nil { return fmt.Errorf("can't read provided file: %s reason: %w", key, err) } diff --git a/cmd/commands/cli/command_orders.go b/cmd/commands/cli/command_orders.go index 38a6885516..7373a2de16 100644 --- a/cmd/commands/cli/command_orders.go +++ b/cmd/commands/cli/command_orders.go @@ -21,7 +21,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "os" "strconv" "strings" @@ -242,7 +242,7 @@ func (c *cliApp) invoice(args []string) (err error) { } filename := fmt.Sprintf("invoice-%v.pdf", args[1]) clio.Info("Writing invoice to", filename) - return ioutil.WriteFile(filename, resp, 0644) + return os.WriteFile(filename, resp, 0644) } func printOrder(o contract.PaymentOrderResponse, rc *remote.Config) { diff --git a/cmd/commands/reset/command_test.go b/cmd/commands/reset/command_test.go index 752826de37..8ec90fcbe3 100644 --- a/cmd/commands/reset/command_test.go +++ b/cmd/commands/reset/command_test.go @@ -19,7 +19,6 @@ package reset import ( "bytes" - "io/ioutil" "os" "testing" @@ -30,7 +29,7 @@ import ( ) func TestActionRun(t *testing.T) { - tempDir, err := ioutil.TempDir("", "") + tempDir, err := os.MkdirTemp("", "") assert.NoError(t, err) defer os.RemoveAll(tempDir) diff --git a/config/config_test.go b/config/config_test.go index d93d3048ee..149f1b6bde 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -19,7 +19,6 @@ package config import ( "flag" - "io/ioutil" "os" "strings" "testing" @@ -42,7 +41,7 @@ func TestUserConfig_Load(t *testing.T) { [openvpn] port = 31338 ` - err := ioutil.WriteFile(configFileName, []byte(toml), 0700) + err := os.WriteFile(configFileName, []byte(toml), 0700) assert.NoError(t, err) // when @@ -79,14 +78,14 @@ func TestUserConfig_Save(t *testing.T) { err = cfg.SaveUserConfig() // then: only user configuration values are stored assert.NoError(t, err) - tomlContent, err := ioutil.ReadFile(configFileName) + tomlContent, err := os.ReadFile(configFileName) assert.NoError(t, err) assert.Contains(t, string(tomlContent), "port = 22822") assert.NotContains(t, string(tomlContent), `proto = "tcp"`) } func NewTempFileName(t *testing.T) string { - file, err := ioutil.TempFile("", "*") + file, err := os.CreateTemp("", "*") assert.NoError(t, err) return file.Name() } diff --git a/consumer/session/session_storage_test.go b/consumer/session/session_storage_test.go index bab75b583d..11990e4134 100644 --- a/consumer/session/session_storage_test.go +++ b/consumer/session/session_storage_test.go @@ -18,7 +18,6 @@ package session import ( - "io/ioutil" "math/big" "os" "testing" @@ -483,7 +482,7 @@ func TestSessionStorage_consumeSessionSpendingEvent(t *testing.T) { } func newStorage() (*Storage, func()) { - dir, err := ioutil.TempDir("", "sessionStorageTest") + dir, err := os.MkdirTemp("", "sessionStorageTest") if err != nil { panic(err) } diff --git a/core/auth/jwt.go b/core/auth/jwt.go index 39ce5315dc..32b73e5606 100644 --- a/core/auth/jwt.go +++ b/core/auth/jwt.go @@ -20,7 +20,7 @@ package auth import ( "time" - "github.com/dgrijalva/jwt-go" + "github.com/golang-jwt/jwt/v4" "github.com/pkg/errors" ) @@ -43,7 +43,7 @@ const JWTCookieName string = "token" type jwtClaims struct { Username string `json:"username"` - jwt.StandardClaims + jwt.RegisteredClaims } const expiresIn = 48 * time.Hour @@ -62,8 +62,8 @@ func (jwtAuth *JWTAuthenticator) CreateToken(username string) (JWT, error) { expirationTime := jwtAuth.getExpirationTime() claims := &jwtClaims{ Username: username, - StandardClaims: jwt.StandardClaims{ - ExpiresAt: expirationTime.Unix(), + RegisteredClaims: jwt.RegisteredClaims{ + ExpiresAt: jwt.NewNumericDate(expirationTime), }, } diff --git a/core/beneficiary/saver_test.go b/core/beneficiary/saver_test.go index 42ae1932ef..03628e584b 100644 --- a/core/beneficiary/saver_test.go +++ b/core/beneficiary/saver_test.go @@ -18,7 +18,6 @@ package beneficiary import ( - "io/ioutil" "os" "testing" @@ -31,7 +30,7 @@ import ( func TestBeneficiaryChangeStatus(t *testing.T) { // given: - dir, err := ioutil.TempDir("/tmp", "mysttest") + dir, err := os.MkdirTemp("/tmp", "mysttest") assert.NoError(t, err) defer os.RemoveAll(dir) diff --git a/core/discovery/proposal/filter_presets_test.go b/core/discovery/proposal/filter_presets_test.go index 6712fec549..b99428d752 100644 --- a/core/discovery/proposal/filter_presets_test.go +++ b/core/discovery/proposal/filter_presets_test.go @@ -21,13 +21,12 @@ import ( "github.com/mysteriumnetwork/node/core/storage/boltdb" "github.com/stretchr/testify/assert" - "io/ioutil" "os" "testing" ) func Test_ProposalFilterPreset(t *testing.T) { - dir, err := ioutil.TempDir("", "consumerTotalsStorageTest") + dir, err := os.MkdirTemp("", "consumerTotalsStorageTest") assert.NoError(t, err) defer os.RemoveAll(dir) diff --git a/core/ip/fallbacks.go b/core/ip/fallbacks.go index 3d398aa9b1..cad61c5b95 100644 --- a/core/ip/fallbacks.go +++ b/core/ip/fallbacks.go @@ -19,7 +19,7 @@ package ip import ( "errors" - "io/ioutil" + "io" "net" "strings" @@ -64,7 +64,7 @@ func RequestAndParsePlainIPResponse(c *requests.HTTPClient, url string) (string, } defer res.Body.Close() - r, err := ioutil.ReadAll(res.Body) + r, err := io.ReadAll(res.Body) if err != nil { return "", err } diff --git a/core/location/gendb/loader.go b/core/location/gendb/loader.go index 91b851f8a7..2aea03872d 100644 --- a/core/location/gendb/loader.go +++ b/core/location/gendb/loader.go @@ -20,7 +20,7 @@ package gendb import ( "compress/gzip" "encoding/base64" - "io/ioutil" + "io" "strings" "github.com/pkg/errors" @@ -37,7 +37,7 @@ func EncodedDataLoader(data string, originalSize int, compressed bool) (decompre } } - decompressed, err = ioutil.ReadAll(reader) + decompressed, err = io.ReadAll(reader) if err != nil { return nil, err } diff --git a/core/location/generator/generator.go b/core/location/generator/generator.go index c7adbc7596..0b507ef9c6 100644 --- a/core/location/generator/generator.go +++ b/core/location/generator/generator.go @@ -23,7 +23,6 @@ import ( "encoding/base64" "flag" "fmt" - "io/ioutil" "os" "path/filepath" "text/template" @@ -44,7 +43,7 @@ func main() { os.Exit(1) } - binaryData, err := ioutil.ReadFile(*dbFilename) + binaryData, err := os.ReadFile(*dbFilename) exitOnError(err) originalDataSize := len(binaryData) diff --git a/core/quality/elastic_search_transport.go b/core/quality/elastic_search_transport.go index 60d1514182..c226ee3a2f 100644 --- a/core/quality/elastic_search_transport.go +++ b/core/quality/elastic_search_transport.go @@ -18,7 +18,7 @@ package quality import ( - "io/ioutil" + "io" "strings" "time" @@ -51,7 +51,7 @@ func (transport *elasticSearchTransport) SendEvent(event Event) error { } defer response.Body.Close() - bodyBytes, err := ioutil.ReadAll(response.Body) + bodyBytes, err := io.ReadAll(response.Body) if err != nil { return errors.Wrapf(err, "error while reading response body") } diff --git a/core/quality/morqa_transport_test.go b/core/quality/morqa_transport_test.go index b0f30e244d..0dd43546ad 100644 --- a/core/quality/morqa_transport_test.go +++ b/core/quality/morqa_transport_test.go @@ -19,7 +19,7 @@ package quality import ( "fmt" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -49,7 +49,7 @@ func TestMORQATransport_SendEvent_HandlesSuccess(t *testing.T) { var events metrics.SignedBatch server := httptest.NewServer(http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) { - body, _ := ioutil.ReadAll(request.Body) + body, _ := io.ReadAll(request.Body) _ = proto.Unmarshal(body, &events) response.WriteHeader(http.StatusAccepted) })) diff --git a/core/quality/mysterium_morqa.go b/core/quality/mysterium_morqa.go index fa86d1ed0f..4081e26d72 100644 --- a/core/quality/mysterium_morqa.go +++ b/core/quality/mysterium_morqa.go @@ -21,7 +21,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "sync" "time" @@ -622,7 +622,7 @@ func (m *MysteriumMORQA) newRequestBinary(method, path string, payload proto.Mes } func parseResponseJSON(response *http.Response, dto interface{}) error { - responseJSON, err := ioutil.ReadAll(response.Body) + responseJSON, err := io.ReadAll(response.Body) if err != nil { return err } diff --git a/core/storage/boltdb/boltdbtest/db.go b/core/storage/boltdb/boltdbtest/db.go index b5e89ea37a..9169d71f92 100644 --- a/core/storage/boltdb/boltdbtest/db.go +++ b/core/storage/boltdb/boltdbtest/db.go @@ -19,7 +19,6 @@ package boltdbtest import ( - "io/ioutil" "os" "testing" @@ -47,7 +46,7 @@ func CleanupDB(t *testing.T, fileName string, db *storm.DB) { // CreateTempFile creates a temporary file and returns its path func CreateTempFile(t *testing.T) string { - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") assert.Nil(t, err) return file.Name() } @@ -62,7 +61,7 @@ func CleanupTempFile(t *testing.T, fileName string) { // CreateTempDir creates a temporary directory func CreateTempDir(t *testing.T) string { - dir, err := ioutil.TempDir("", "") + dir, err := os.MkdirTemp("", "") assert.Nil(t, err) return dir } diff --git a/go.mod b/go.mod index d7e9836a73..9ba3b3f52f 100644 --- a/go.mod +++ b/go.mod @@ -14,13 +14,13 @@ require ( github.com/aws/aws-sdk-go-v2/service/s3 v1.40.2 github.com/cenkalti/backoff/v4 v4.0.0 github.com/chzyer/readline v1.5.1 - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/ethereum/go-ethereum v1.13.5 github.com/gin-contrib/cors v1.4.0 github.com/gin-gonic/gin v1.9.1 github.com/go-openapi/strfmt v0.21.7 github.com/go-ozzo/ozzo-validation v3.6.0+incompatible github.com/gofrs/uuid v4.4.0+incompatible + github.com/golang-jwt/jwt/v4 v4.5.0 github.com/golang/protobuf v1.5.3 github.com/google/go-github/v28 v28.1.1 github.com/google/go-github/v35 v35.2.0 @@ -31,7 +31,7 @@ require ( github.com/koron/go-ssdp v0.0.4 github.com/libp2p/go-libp2p v0.32.1 github.com/magefile/mage v1.15.0 - github.com/mholt/archiver v3.1.1+incompatible + github.com/mholt/archiver/v3 v3.5.1 github.com/miekg/dns v1.1.56 github.com/multiformats/go-multiaddr v0.12.0 github.com/mysteriumnetwork/EventBus v0.0.0-20220415063055-d22cb121672c @@ -75,7 +75,7 @@ require ( require ( github.com/StackExchange/wmi v1.2.1 // indirect - github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6 // indirect + github.com/andybalholm/brotli v1.0.6 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.14 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.13.43 // indirect @@ -114,7 +114,7 @@ require ( github.com/denisenkom/go-mssqldb v0.12.3 // indirect github.com/didip/tollbooth/v5 v5.2.0 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/dsnet/compress v0.0.1 // indirect + github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect github.com/elastic/gosigar v0.14.2 // indirect github.com/emirpasic/gods v1.12.0 // indirect github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 // indirect @@ -138,7 +138,6 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721 // indirect github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect github.com/google/btree v1.0.1 // indirect github.com/google/go-cmp v0.6.0 // indirect @@ -164,7 +163,7 @@ require ( github.com/klauspost/compress v1.17.2 // indirect github.com/klauspost/cpuid v1.3.1 // indirect github.com/klauspost/cpuid/v2 v2.2.6 // indirect - github.com/klauspost/pgzip v1.2.1 // indirect + github.com/klauspost/pgzip v1.2.6 // indirect github.com/klauspost/reedsolomon v1.9.9 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/lib/pq v1.10.9 // indirect @@ -185,7 +184,6 @@ require ( github.com/mdlayher/genetlink v1.1.0 // indirect github.com/mdlayher/netlink v1.4.2 // indirect github.com/mdlayher/socket v0.0.0-20211102153432-57e3fa563ecb // indirect - github.com/mholt/archiver/v3 v3.3.0 // indirect github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect github.com/minio/sha256-simd v1.0.1 // indirect @@ -207,7 +205,7 @@ require ( github.com/multiformats/go-varint v0.0.7 // indirect github.com/nats-io/nkeys v0.4.6 // indirect github.com/nats-io/nuid v1.0.1 // indirect - github.com/nwaples/rardecode v1.0.0 // indirect + github.com/nwaples/rardecode v1.1.3 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/onsi/ginkgo/v2 v2.13.1 // indirect github.com/opencontainers/runtime-spec v1.1.0 // indirect @@ -215,7 +213,7 @@ require ( github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect - github.com/pierrec/lz4 v2.0.5+incompatible // indirect + github.com/pierrec/lz4/v4 v4.1.18 // indirect github.com/pion/dtls/v2 v2.2.7 // indirect github.com/pion/logging v0.2.2 // indirect github.com/pion/transport/v2 v2.2.1 // indirect @@ -243,7 +241,7 @@ require ( github.com/tklauser/numcpus v0.6.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect - github.com/ulikunitz/xz v0.5.6 // indirect + github.com/ulikunitz/xz v0.5.11 // indirect github.com/xanzy/ssh-agent v0.3.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect diff --git a/go.sum b/go.sum index 2d3439cc8a..58b6c2b446 100644 --- a/go.sum +++ b/go.sum @@ -78,8 +78,9 @@ github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBb github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6 h1:bZ28Hqta7TFAK3Q08CMvv8y3/8ATaEqv2nGoc6yff6c= -github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6/go.mod h1:+lx6/Aqd1kLJ1GQfkvOnaZ1WGmLpMpbprPuIOOZX30U= +github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= +github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI= +github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= @@ -249,7 +250,6 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etly github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/denisenkom/go-mssqldb v0.12.3 h1:pBSGx9Tq67pBOTLmxNuirNTeB8Vjmf886Kx+8Y+8shw= github.com/denisenkom/go-mssqldb v0.12.3/go.mod h1:k0mtMFOnU+AihqFxPMiF05rtiDrorD1Vrm1KEz5hxDo= -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/didip/tollbooth/v5 v5.2.0 h1:6AfMZByPqSkKwt8ocKEa6G73beowz6wAeeFgeTVwZHY= @@ -260,8 +260,8 @@ github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4 github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q= -github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo= +github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY= +github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s= github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elastic/gosigar v0.12.0/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= @@ -386,12 +386,11 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= +github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI= -github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721 h1:KRMr9A3qfbVM7iV/WcLY/rL5LICqwMHLhwRXKu99fXw= -github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721/go.mod h1:xEhNfoBDX1hzLm2Nf80qUvZ2sVwoMZ8d6IE2SrsQfh4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -426,6 +425,7 @@ github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -575,7 +575,7 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.9.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= @@ -586,8 +586,9 @@ github.com/klauspost/cpuid v1.3.1/go.mod h1:bYW4mA6ZgKPob1/Dlai2LviZJO7KGI3uoWLd github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM= -github.com/klauspost/pgzip v1.2.1/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= +github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= +github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= +github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/reedsolomon v1.9.9 h1:qCL7LZlv17xMixl55nq2/Oa1Y86nfO8EqDfv2GHND54= github.com/klauspost/reedsolomon v1.9.9/go.mod h1:O7yFFHiQwDR6b2t63KPUpccPtNdp5ADgh1gg4fd12wo= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= @@ -685,10 +686,8 @@ github.com/mdlayher/socket v0.0.0-20210307095302-262dc9984e00/go.mod h1:GAFlyu4/ github.com/mdlayher/socket v0.0.0-20211007213009-516dcbdf0267/go.mod h1:nFZ1EtZYK8Gi/k6QNu7z7CgO20i/4ExeQswwWuPmG/g= github.com/mdlayher/socket v0.0.0-20211102153432-57e3fa563ecb h1:2dC7L10LmTqlyMVzFJ00qM25lqESg9Z4u3GuEXN5iHY= github.com/mdlayher/socket v0.0.0-20211102153432-57e3fa563ecb/go.mod h1:nFZ1EtZYK8Gi/k6QNu7z7CgO20i/4ExeQswwWuPmG/g= -github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU= -github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU= -github.com/mholt/archiver/v3 v3.3.0 h1:vWjhY8SQp5yzM9P6OJ/eZEkmi3UAbRrxCq48MxjAzig= -github.com/mholt/archiver/v3 v3.3.0/go.mod h1:YnQtqsp+94Rwd0D/rk5cnLrxusUBUXg+08Ebtr1Mqao= +github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo= +github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= @@ -792,8 +791,9 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMBOs= -github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= +github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= +github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc= +github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/oleksandr/bonjour v0.0.0-20160508152359-5dcf00d8b228 h1:Cvfd2dOlXIPTeEkOT/h8PyK4phBngOM4at9/jlgy7d4= @@ -831,8 +831,9 @@ github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZO github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= +github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pion/dtls/v2 v2.2.7 h1:cSUBsETxepsCSFSxC3mc/aDo14qQLMSL+O6IjG28yV8= github.com/pion/dtls/v2 v2.2.7/go.mod h1:8WiMkebSHFD0T+dIU+UeBaoV7kDhOW5oDCzZ7WZ/F9s= github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= @@ -1012,8 +1013,10 @@ github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLY github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8= -github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= +github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ulikunitz/xz v0.5.9/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= +github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= diff --git a/identity/cache.go b/identity/cache.go index e68774104a..e55b9a30c3 100644 --- a/identity/cache.go +++ b/identity/cache.go @@ -19,7 +19,6 @@ package identity import ( "encoding/json" - "io/ioutil" "os" "path/filepath" @@ -75,7 +74,7 @@ func (ic *IdentityCache) cacheExists() bool { } func (ic *IdentityCache) readCache() (cache *cacheData, err error) { - data, err := ioutil.ReadFile(ic.File) + data, err := os.ReadFile(ic.File) if err != nil { return nil, err } @@ -94,6 +93,6 @@ func (ic *IdentityCache) writeCache(cache cacheData) (err error) { return } - err = ioutil.WriteFile(ic.File, cacheString, 0644) + err = os.WriteFile(ic.File, cacheString, 0644) return } diff --git a/identity/keystore_filesystem.go b/identity/keystore_filesystem.go index 257a810cb9..0eadece2d4 100644 --- a/identity/keystore_filesystem.go +++ b/identity/keystore_filesystem.go @@ -26,7 +26,7 @@ import ( "errors" "fmt" "io" - "io/ioutil" + "os" "sync" "time" @@ -251,7 +251,7 @@ func (u *unlocked) deriveKey() ([]byte, error) { func loadStoredKey(addr common.Address, filename, auth string) (*ethKs.Key, error) { // Load the key from the keystore and decrypt its contents - keyjson, err := ioutil.ReadFile(filename) + keyjson, err := os.ReadFile(filename) if err != nil { return nil, err } diff --git a/identity/registry/storage_test.go b/identity/registry/storage_test.go index a19f8e71d4..f7393e8c21 100644 --- a/identity/registry/storage_test.go +++ b/identity/registry/storage_test.go @@ -18,7 +18,6 @@ package registry import ( - "io/ioutil" "os" "testing" @@ -29,7 +28,7 @@ import ( func TestRegistrationStatusStorage(t *testing.T) { var chainID int64 = 1 - dir, err := ioutil.TempDir("", "consumerTotalsStorageTest") + dir, err := os.MkdirTemp("", "consumerTotalsStorageTest") assert.NoError(t, err) defer os.RemoveAll(dir) diff --git a/identity/resident_country_test.go b/identity/resident_country_test.go index 34a38a893b..0c827c4552 100644 --- a/identity/resident_country_test.go +++ b/identity/resident_country_test.go @@ -18,7 +18,6 @@ package identity import ( - "io/ioutil" "os" "sync" "testing" @@ -61,7 +60,7 @@ func TestResidentEvent(t *testing.T) { } func NewTempFileName(t *testing.T) string { - file, err := ioutil.TempFile("", "*") + file, err := os.CreateTemp("", "*") assert.NoError(t, err) return file.Name() } diff --git a/logconfig/collector.go b/logconfig/collector.go index 3ba9603e2d..787eaf82ff 100644 --- a/logconfig/collector.go +++ b/logconfig/collector.go @@ -19,11 +19,11 @@ package logconfig import ( "io/fs" - "io/ioutil" + "os" "path" "strings" - "github.com/mholt/archiver" + "github.com/mholt/archiver/v3" "github.com/pkg/errors" ) @@ -62,18 +62,22 @@ func (c *Collector) Archive() (outputFilepath string, err error) { func (c *Collector) logFilepaths() (result []string, err error) { filename := path.Base(c.options.Filepath) dir := path.Dir(c.options.Filepath) - files, err := ioutil.ReadDir(dir) + files, err := os.ReadDir(dir) if err != nil { return nil, errors.Wrap(err, "failed to read directory: "+dir) } var mostRecent fs.FileInfo for _, f := range files { + fInfo, err := f.Info() + if err != nil { + return nil, errors.Wrap(err, "failed to get file info: "+f.Name()) + } if f.Name() == filename+".log" { result = append(result, path.Join(dir, f.Name())) - } else if strings.Contains(f.Name(), ".log.gz") && f.Mode().IsRegular() && - (mostRecent == nil || f.ModTime().After(mostRecent.ModTime())) { - mostRecent = f + } else if strings.Contains(f.Name(), ".log.gz") && fInfo.Mode().IsRegular() && + (mostRecent == nil || fInfo.ModTime().After(mostRecent.ModTime())) { + mostRecent = fInfo } } if mostRecent != nil { diff --git a/logconfig/collector_test.go b/logconfig/collector_test.go index bb4b33814b..4d0dfeedf5 100644 --- a/logconfig/collector_test.go +++ b/logconfig/collector_test.go @@ -18,7 +18,6 @@ package logconfig import ( - "io/ioutil" "os" "path" "testing" @@ -96,13 +95,13 @@ func TestCollector_Archive(t *testing.T) { } func NewTempFileName(t *testing.T, dir, pattern string) string { - file, err := ioutil.TempFile(dir, pattern) + file, err := os.CreateTemp(dir, pattern) assert.NoError(t, err) return file.Name() } func NewTempDirName(t *testing.T, pattern string) string { - dir, err := ioutil.TempDir("", pattern) + dir, err := os.MkdirTemp("", pattern) assert.NoError(t, err) return dir } diff --git a/logconfig/rollingwriter/rollingwriter.go b/logconfig/rollingwriter/rollingwriter.go index c8319b93ad..d93efddd58 100644 --- a/logconfig/rollingwriter/rollingwriter.go +++ b/logconfig/rollingwriter/rollingwriter.go @@ -18,8 +18,8 @@ package rollingwriter import ( + "fmt" "io" - "io/ioutil" "os" "path" "sort" @@ -61,7 +61,7 @@ func (w *RollingWriter) Write(b []byte) (int, error) { // rollingWriter only handles file rolling at runtime, but if the node is restarted, the count is lost thus we have // to do this manually. func (w *RollingWriter) CleanObsoleteLogs() error { - files, err := ioutil.ReadDir(w.config.LogPath) + files, err := os.ReadDir(w.config.LogPath) if err != nil { return err } @@ -69,7 +69,11 @@ func (w *RollingWriter) CleanObsoleteLogs() error { baseFilename := w.config.FileName + ".log" for _, file := range files { if strings.Contains(file.Name(), baseFilename) && file.Name() != baseFilename { - oldLogFiles = append(oldLogFiles, file) + fInfo, err := file.Info() + if err != nil { + return fmt.Errorf("failed to get file info: %w", err) + } + oldLogFiles = append(oldLogFiles, fInfo) } } if len(oldLogFiles) <= w.config.MaxRemain { diff --git a/pilvytis/api.go b/pilvytis/api.go index 098f0ddaaa..a3de47da63 100644 --- a/pilvytis/api.go +++ b/pilvytis/api.go @@ -21,7 +21,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "runtime" @@ -221,7 +221,7 @@ func (a *API) GetPaymentGatewayOrderInvoice(id identity.Identity, oid string) ([ if err != nil { return nil, err } - return ioutil.ReadAll(res.Body) + return io.ReadAll(res.Body) } // GatewayClientCallback triggers a payment callback from the client-side. diff --git a/session/pingpong/hermes_promise_storage_test.go b/session/pingpong/hermes_promise_storage_test.go index 2ab1758327..9a5688ac44 100644 --- a/session/pingpong/hermes_promise_storage_test.go +++ b/session/pingpong/hermes_promise_storage_test.go @@ -18,7 +18,6 @@ package pingpong import ( - "io/ioutil" "math/big" "os" "testing" @@ -31,7 +30,7 @@ import ( ) func TestHermesPromiseStorage(t *testing.T) { - dir, err := ioutil.TempDir("", "hermesPromiseStorageTest") + dir, err := os.MkdirTemp("", "hermesPromiseStorageTest") assert.NoError(t, err) defer os.RemoveAll(dir) @@ -106,7 +105,7 @@ func TestHermesPromiseStorage(t *testing.T) { } func TestHermesPromiseStorageDelete(t *testing.T) { - dir, err := ioutil.TempDir("", "hermesPromiseStorageTest") + dir, err := os.MkdirTemp("", "hermesPromiseStorageTest") assert.NoError(t, err) defer os.RemoveAll(dir) diff --git a/session/pingpong/invoice_payer_test.go b/session/pingpong/invoice_payer_test.go index cf22b50e8a..4a358e4007 100644 --- a/session/pingpong/invoice_payer_test.go +++ b/session/pingpong/invoice_payer_test.go @@ -18,7 +18,6 @@ package pingpong import ( - "io/ioutil" "math/big" "os" "sync" @@ -87,7 +86,7 @@ func Test_InvoicePayer_Start_Stop(t *testing.T) { } func Test_InvoicePayer_SendsMessage(t *testing.T) { - dir, err := ioutil.TempDir("", "exchange_message_tracker_test") + dir, err := os.MkdirTemp("", "exchange_message_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -156,7 +155,7 @@ func Test_InvoicePayer_SendsMessage(t *testing.T) { } func Test_InvoicePayer_SendsMessage_OnFreeService(t *testing.T) { - dir, err := ioutil.TempDir("", "exchange_message_tracker_test") + dir, err := os.MkdirTemp("", "exchange_message_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -223,7 +222,7 @@ func Test_InvoicePayer_SendsMessage_OnFreeService(t *testing.T) { } func Test_InvoicePayer_BubblesErrors(t *testing.T) { - dir, err := ioutil.TempDir("", "exchange_message_tracker_test") + dir, err := os.MkdirTemp("", "exchange_message_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) diff --git a/session/pingpong/invoice_storage_test.go b/session/pingpong/invoice_storage_test.go index 80385af91a..988f7f1758 100644 --- a/session/pingpong/invoice_storage_test.go +++ b/session/pingpong/invoice_storage_test.go @@ -18,7 +18,6 @@ package pingpong import ( - "io/ioutil" "math/big" "os" "testing" @@ -50,7 +49,7 @@ var invoiceTwo = crypto.Invoice{ func TestProviderInvoiceStorage(t *testing.T) { providerID := identity.FromAddress("0xprovider") - dir, err := ioutil.TempDir("", "providerInvoiceTest") + dir, err := os.MkdirTemp("", "providerInvoiceTest") assert.NoError(t, err) defer os.RemoveAll(dir) diff --git a/session/pingpong/invoice_tracker_test.go b/session/pingpong/invoice_tracker_test.go index efeb059b4a..55c6300c3e 100644 --- a/session/pingpong/invoice_tracker_test.go +++ b/session/pingpong/invoice_tracker_test.go @@ -19,7 +19,6 @@ package pingpong import ( "encoding/hex" - "io/ioutil" "math/big" "os" "strings" @@ -94,7 +93,7 @@ func (mac *mockHermesCaller) RefreshLatestProviderPromise(chainID int64, id stri } func Test_InvoiceTracker_Start_Stop(t *testing.T) { - dir, err := ioutil.TempDir("", "invoice_tracker_test") + dir, err := os.MkdirTemp("", "invoice_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -143,7 +142,7 @@ func Test_InvoiceTracker_Start_Stop(t *testing.T) { } func Test_InvoiceTracker_Start_RefusesLargeFee(t *testing.T) { - dir, err := ioutil.TempDir("", "invoice_tracker_test") + dir, err := os.MkdirTemp("", "invoice_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -192,7 +191,7 @@ func Test_InvoiceTracker_Start_RefusesLargeFee(t *testing.T) { } func Test_InvoiceTracker_Start_BubblesHermesCheckError(t *testing.T) { - dir, err := ioutil.TempDir("", "invoice_tracker_test") + dir, err := os.MkdirTemp("", "invoice_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -243,7 +242,7 @@ func Test_InvoiceTracker_Start_BubblesHermesCheckError(t *testing.T) { } func Test_InvoiceTracker_BubblesErrors(t *testing.T) { - dir, err := ioutil.TempDir("", "invoice_tracker_test") + dir, err := os.MkdirTemp("", "invoice_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -300,7 +299,7 @@ func Test_InvoiceTracker_BubblesErrors(t *testing.T) { } func Test_InvoiceTracker_SendsInvoice(t *testing.T) { - dir, err := ioutil.TempDir("", "invoice_tracker_test") + dir, err := os.MkdirTemp("", "invoice_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -353,7 +352,7 @@ func Test_InvoiceTracker_SendsInvoice(t *testing.T) { } func Test_InvoiceTracker_FirstInvoice_Has_Static_Value(t *testing.T) { - dir, err := ioutil.TempDir("", "invoice_tracker_test") + dir, err := os.MkdirTemp("", "invoice_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -405,7 +404,7 @@ func Test_InvoiceTracker_FirstInvoice_Has_Static_Value(t *testing.T) { } func Test_InvoiceTracker_FreeServiceSendsInvoices(t *testing.T) { - dir, err := ioutil.TempDir("", "invoice_tracker_test") + dir, err := os.MkdirTemp("", "invoice_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -564,7 +563,7 @@ func Test_calculateMaxNotReceivedExchangeMessageCount(t *testing.T) { } func generateExchangeMessage(t *testing.T, amount *big.Int, invoice crypto.Invoice, channel string) (crypto.ExchangeMessage, string) { - dir, err := ioutil.TempDir("", "invoice_tracker_test") + dir, err := os.MkdirTemp("", "invoice_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) @@ -590,7 +589,7 @@ func generateExchangeMessage(t *testing.T, amount *big.Int, invoice crypto.Invoi } func TestInvoiceTracker_receiveExchangeMessageOrTimeout(t *testing.T) { - dir, err := ioutil.TempDir("", "invoice_tracker_test") + dir, err := os.MkdirTemp("", "invoice_tracker_test") assert.Nil(t, err) defer os.RemoveAll(dir) diff --git a/session/pingpong/settlement_history_storage_test.go b/session/pingpong/settlement_history_storage_test.go index ef128225c9..33badc24e0 100644 --- a/session/pingpong/settlement_history_storage_test.go +++ b/session/pingpong/settlement_history_storage_test.go @@ -18,7 +18,6 @@ package pingpong import ( - "io/ioutil" "math/big" "os" "testing" @@ -32,7 +31,7 @@ import ( ) func TestSettlementHistoryStorage(t *testing.T) { - dir, err := ioutil.TempDir("", "providerInvoiceTest") + dir, err := os.MkdirTemp("", "providerInvoiceTest") assert.NoError(t, err) defer os.RemoveAll(dir) diff --git a/supervisor/config/config.go b/supervisor/config/config.go index 5de03687c4..17e545ca20 100644 --- a/supervisor/config/config.go +++ b/supervisor/config/config.go @@ -20,7 +20,7 @@ package config import ( "errors" "fmt" - "io/ioutil" + "os" "path/filepath" "strings" @@ -53,7 +53,7 @@ func (c Config) Write() error { if err != nil { return fmt.Errorf("could not encode configuration: %w", err) } - if err := ioutil.WriteFile(confPath, []byte(out.String()), 0700); err != nil { + if err := os.WriteFile(confPath, []byte(out.String()), 0700); err != nil { return fmt.Errorf("could not write %q: %w", confPath, err) } return nil diff --git a/tequilapi/client/http_client.go b/tequilapi/client/http_client.go index 71a9868eb8..6546fcaa4d 100644 --- a/tequilapi/client/http_client.go +++ b/tequilapi/client/http_client.go @@ -22,7 +22,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "time" @@ -147,7 +146,7 @@ func parseResponseJSON(response *http.Response, dto interface{}) error { // NopCloser returns a ReadCloser with a no-op Close method wrapping the provided Reader r. // parseResponseError "empties" the contents of an errored response // this way the response can be read and parsed again further down the line - response.Body = ioutil.NopCloser(b) + response.Body = io.NopCloser(b) return nil } diff --git a/tequilapi/endpoints/assets/docs.go b/tequilapi/endpoints/assets/docs.go index 60716fddf3..da1c1bb011 100644 --- a/tequilapi/endpoints/assets/docs.go +++ b/tequilapi/endpoints/assets/docs.go @@ -7,7 +7,6 @@ import ( "compress/gzip" "fmt" "io" - "io/ioutil" "net/http" "os" pathpkg "path" @@ -117,7 +116,7 @@ func (f *vfsgen۰CompressedFile) Read(p []byte) (n int, err error) { } if f.grPos < f.seekPos { // Fast-forward. - _, err = io.CopyN(ioutil.Discard, f.gr, f.seekPos-f.grPos) + _, err = io.CopyN(io.Discard, f.gr, f.seekPos-f.grPos) if err != nil { return 0, err } diff --git a/tequilapi/endpoints/validation_test.go b/tequilapi/endpoints/validation_test.go index 4a46dc2898..806c684f87 100644 --- a/tequilapi/endpoints/validation_test.go +++ b/tequilapi/endpoints/validation_test.go @@ -19,7 +19,6 @@ package endpoints import ( "fmt" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -80,7 +79,7 @@ func Test_EthEndpoints(t *testing.T) { } func NewTempFileName(t *testing.T) string { - file, err := ioutil.TempFile("", "*") + file, err := os.CreateTemp("", "*") assert.NoError(t, err) return file.Name() } diff --git a/tequilapi/launchpad/api_test.go b/tequilapi/launchpad/api_test.go index 55957a7b76..a83c080af6 100644 --- a/tequilapi/launchpad/api_test.go +++ b/tequilapi/launchpad/api_test.go @@ -19,7 +19,7 @@ package launchpad import ( "bytes" - "io/ioutil" + "io" "net/http" "testing" @@ -33,7 +33,7 @@ func (m *mockLaunchpadAPI) Do(req *http.Request) (*http.Response, error) { return &http.Response{ Status: "200 OK", StatusCode: http.StatusOK, - Body: ioutil.NopCloser(bytes.NewBufferString(responseJSON)), + Body: io.NopCloser(bytes.NewBufferString(responseJSON)), }, nil } diff --git a/ui/server_test.go b/ui/server_test.go index 0dcde42da8..a276d1b244 100644 --- a/ui/server_test.go +++ b/ui/server_test.go @@ -18,7 +18,6 @@ package ui import ( - "io/ioutil" "net/http" "os" "testing" @@ -40,7 +39,7 @@ func (j *jwtAuth) ValidateToken(token string) (bool, error) { func Test_Server_ServesHTML(t *testing.T) { // given - tmpDIr, err := ioutil.TempDir("", "nodeuiversiontest") + tmpDIr, err := os.MkdirTemp("", "nodeuiversiontest") assert.NoError(t, err) defer os.Remove(tmpDIr) diff --git a/ui/versionmanager/version_config.go b/ui/versionmanager/version_config.go index e43e16d903..e3209c8ac5 100644 --- a/ui/versionmanager/version_config.go +++ b/ui/versionmanager/version_config.go @@ -19,7 +19,6 @@ package versionmanager import ( "encoding/json" - "io/ioutil" "os" "path/filepath" ) @@ -91,7 +90,7 @@ func (vm *VersionConfig) exists() (bool, error) { } func (vm *VersionConfig) read() (nodeUIVersion, error) { - data, err := ioutil.ReadFile(vm.whichFilePath()) + data, err := os.ReadFile(vm.whichFilePath()) if err != nil { return nodeUIVersion{}, err } @@ -128,7 +127,7 @@ func (vm *VersionConfig) write(w nodeUIVersion) error { return err } - return ioutil.WriteFile(vm.whichFilePath(), configJSON, 0644) + return os.WriteFile(vm.whichFilePath(), configJSON, 0644) } func (vm *VersionConfig) uiDir() string { diff --git a/ui/versionmanager/version_manager.go b/ui/versionmanager/version_manager.go index 12fce159b6..1a9069032b 100644 --- a/ui/versionmanager/version_manager.go +++ b/ui/versionmanager/version_manager.go @@ -22,7 +22,6 @@ import ( "compress/gzip" "fmt" "io" - "io/ioutil" "os" "path/filepath" "time" @@ -72,7 +71,7 @@ func NewVersionManager( func (vm *VersionManager) ListLocalVersions() ([]LocalVersion, error) { var versions = make([]LocalVersion, 0) - files, err := ioutil.ReadDir(vm.versionConfig.uiDir()) + files, err := os.ReadDir(vm.versionConfig.uiDir()) if err != nil { if os.IsNotExist(err) { return versions, nil diff --git a/ui/versionmanager/version_manager_test.go b/ui/versionmanager/version_manager_test.go index 689e783db7..3850ffe5da 100644 --- a/ui/versionmanager/version_manager_test.go +++ b/ui/versionmanager/version_manager_test.go @@ -18,7 +18,6 @@ package versionmanager import ( - "io/ioutil" "net/http" "os" "strings" @@ -42,7 +41,7 @@ func (m *mockServer) SwitchUI(path string) { func TestSwitchUI(t *testing.T) { // given - tmpDIr, err := ioutil.TempDir("", "nodeuiversiontest") + tmpDIr, err := os.MkdirTemp("", "nodeuiversiontest") assert.NoError(t, err) defer os.RemoveAll(tmpDIr) @@ -92,7 +91,7 @@ func TestSwitchUI(t *testing.T) { func TestListLocal(t *testing.T) { // given - tmpDIr, err := ioutil.TempDir("", "nodeuiversiontest") + tmpDIr, err := os.MkdirTemp("", "nodeuiversiontest") assert.NoError(t, err) defer os.RemoveAll(tmpDIr) @@ -127,7 +126,7 @@ func TestListLocal(t *testing.T) { func TestBundledVersion(t *testing.T) { // given - tmpDIr, err := ioutil.TempDir("", "nodeuiversiontest") + tmpDIr, err := os.MkdirTemp("", "nodeuiversiontest") assert.NoError(t, err) defer os.RemoveAll(tmpDIr) @@ -152,7 +151,7 @@ func TestBundledVersion(t *testing.T) { func TestListLocalDirectoryRemoved(t *testing.T) { // given - tmpDIr, err := ioutil.TempDir("", "nodeuiversiontest") + tmpDIr, err := os.MkdirTemp("", "nodeuiversiontest") assert.NoError(t, err) defer os.RemoveAll(tmpDIr) diff --git a/utils/fileutil/fileutil.go b/utils/fileutil/fileutil.go index 62707e9fb5..b80982dc98 100644 --- a/utils/fileutil/fileutil.go +++ b/utils/fileutil/fileutil.go @@ -36,7 +36,6 @@ package fileutil import ( - "io/ioutil" "os" "path/filepath" "sort" @@ -82,7 +81,7 @@ func CopyDirs(src, dest string) error { // It tries to also copy it with the same permissions, // if thats not possible 0644 is used. func copyFile(src, dest string) error { - data, err := ioutil.ReadFile(src) + data, err := os.ReadFile(src) if err != nil { return err } @@ -92,7 +91,7 @@ func copyFile(src, dest string) error { perm = info.Mode().Perm() } - err = ioutil.WriteFile(dest, data, perm) + err = os.WriteFile(dest, data, perm) if err != nil { return err }