From c1f2505861f3f96a183ee86a310fe00733f39eae Mon Sep 17 00:00:00 2001 From: web3-bot Date: Wed, 23 Aug 2023 09:27:07 +0000 Subject: [PATCH 1/5] chore: bump go.mod to Go 1.20 and run go fix --- go.mod | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- go.sum | 3 - 2 files changed, 195 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 44c5e74..fddde28 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ipfs/ipfs-ds-convert -go 1.16 +go 1.20 require ( github.com/ipfs/go-datastore v0.4.6 @@ -16,3 +16,197 @@ require ( github.com/syndtr/goleveldb v1.0.0 github.com/urfave/cli v1.22.4 ) + +require ( + bazil.org/fuse v0.0.0-20200117225306-7b5117fecadc // indirect + github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect + github.com/Stebalien/go-bitfield v0.0.1 // indirect + github.com/alexbrainman/goissue34681 v0.0.0-20191006012335-3fc7a47baff5 // indirect + github.com/benbjohnson/clock v1.1.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/blang/semver/v4 v4.0.0 // indirect + github.com/btcsuite/btcd v0.22.0-beta // indirect + github.com/cenkalti/backoff v2.2.1+incompatible // indirect + github.com/cenkalti/backoff/v4 v4.1.1 // indirect + github.com/cespare/xxhash v1.1.0 // indirect + github.com/cespare/xxhash/v2 v2.1.1 // indirect + github.com/cheekybits/genny v1.0.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect + github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect + github.com/cskr/pubsub v1.0.2 // indirect + github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect + github.com/dgraph-io/badger v1.6.2 // indirect + github.com/dgraph-io/ristretto v0.0.2 // indirect + github.com/dustin/go-humanize v1.0.0 // indirect + github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect + github.com/flynn/noise v1.0.0 // indirect + github.com/francoispqt/gojay v1.2.13 // indirect + github.com/fsnotify/fsnotify v1.4.9 // indirect + github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect + github.com/google/gopacket v1.1.19 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/gorilla/websocket v1.4.2 // indirect + github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e // indirect + github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/huin/goupnp v1.0.2 // indirect + github.com/ipfs/bbloom v0.0.4 // indirect + github.com/ipfs/go-bitswap v0.4.0 // indirect + github.com/ipfs/go-block-format v0.0.3 // indirect + github.com/ipfs/go-blockservice v0.1.7 // indirect + github.com/ipfs/go-cid v0.0.7 // indirect + github.com/ipfs/go-cidutil v0.0.2 // indirect + github.com/ipfs/go-fetcher v1.5.0 // indirect + github.com/ipfs/go-filestore v0.0.3 // indirect + github.com/ipfs/go-graphsync v0.8.0 // indirect + github.com/ipfs/go-ipfs-blockstore v0.1.6 // indirect + github.com/ipfs/go-ipfs-chunker v0.0.5 // indirect + github.com/ipfs/go-ipfs-delay v0.0.1 // indirect + github.com/ipfs/go-ipfs-ds-help v0.1.1 // indirect + github.com/ipfs/go-ipfs-exchange-interface v0.0.1 // indirect + github.com/ipfs/go-ipfs-exchange-offline v0.0.1 // indirect + github.com/ipfs/go-ipfs-files v0.0.8 // indirect + github.com/ipfs/go-ipfs-keystore v0.0.2 // indirect + github.com/ipfs/go-ipfs-pinner v0.1.2 // indirect + github.com/ipfs/go-ipfs-posinfo v0.0.1 // indirect + github.com/ipfs/go-ipfs-pq v0.0.2 // indirect + github.com/ipfs/go-ipfs-provider v0.6.1 // indirect + github.com/ipfs/go-ipfs-routing v0.1.0 // indirect + github.com/ipfs/go-ipfs-util v0.0.2 // indirect + github.com/ipfs/go-ipld-cbor v0.0.5 // indirect + github.com/ipfs/go-ipld-format v0.2.0 // indirect + github.com/ipfs/go-ipld-git v0.1.1 // indirect + github.com/ipfs/go-ipld-legacy v0.1.0 // indirect + github.com/ipfs/go-ipns v0.1.2 // indirect + github.com/ipfs/go-log v1.0.5 // indirect + github.com/ipfs/go-log/v2 v2.3.0 // indirect + github.com/ipfs/go-merkledag v0.4.0 // indirect + github.com/ipfs/go-metrics-interface v0.0.1 // indirect + github.com/ipfs/go-mfs v0.1.2 // indirect + github.com/ipfs/go-namesys v0.3.1 // indirect + github.com/ipfs/go-path v0.1.2 // indirect + github.com/ipfs/go-peertaskqueue v0.4.0 // indirect + github.com/ipfs/go-unixfs v0.2.5 // indirect + github.com/ipfs/go-unixfsnode v1.1.3 // indirect + github.com/ipfs/go-verifcid v0.0.1 // indirect + github.com/ipfs/interface-go-ipfs-core v0.5.1 // indirect + github.com/ipld/go-codec-dagpb v1.3.0 // indirect + github.com/ipld/go-ipld-prime v0.12.2 // indirect + github.com/jackpal/go-nat-pmp v1.0.2 // indirect + github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect + github.com/jbenet/goprocess v0.1.4 // indirect + github.com/klauspost/compress v1.11.7 // indirect + github.com/klauspost/cpuid/v2 v2.0.9 // indirect + github.com/koron/go-ssdp v0.0.2 // indirect + github.com/libp2p/go-addr-util v0.1.0 // indirect + github.com/libp2p/go-buffer-pool v0.0.2 // indirect + github.com/libp2p/go-cidranger v1.1.0 // indirect + github.com/libp2p/go-conn-security-multistream v0.2.1 // indirect + github.com/libp2p/go-doh-resolver v0.3.1 // indirect + github.com/libp2p/go-eventbus v0.2.1 // indirect + github.com/libp2p/go-flow-metrics v0.0.3 // indirect + github.com/libp2p/go-libp2p v0.15.0 // indirect + github.com/libp2p/go-libp2p-asn-util v0.0.0-20200825225859-85005c6cf052 // indirect + github.com/libp2p/go-libp2p-autonat v0.4.2 // indirect + github.com/libp2p/go-libp2p-blankhost v0.2.0 // indirect + github.com/libp2p/go-libp2p-circuit v0.4.0 // indirect + github.com/libp2p/go-libp2p-connmgr v0.2.4 // indirect + github.com/libp2p/go-libp2p-core v0.9.0 // indirect + github.com/libp2p/go-libp2p-discovery v0.5.1 // indirect + github.com/libp2p/go-libp2p-kad-dht v0.13.1 // indirect + github.com/libp2p/go-libp2p-kbucket v0.4.7 // indirect + github.com/libp2p/go-libp2p-loggables v0.1.0 // indirect + github.com/libp2p/go-libp2p-mplex v0.4.1 // indirect + github.com/libp2p/go-libp2p-nat v0.0.6 // indirect + github.com/libp2p/go-libp2p-noise v0.2.2 // indirect + github.com/libp2p/go-libp2p-peerstore v0.2.8 // indirect + github.com/libp2p/go-libp2p-pnet v0.2.0 // indirect + github.com/libp2p/go-libp2p-pubsub v0.5.4 // indirect + github.com/libp2p/go-libp2p-pubsub-router v0.4.0 // indirect + github.com/libp2p/go-libp2p-quic-transport v0.12.0 // indirect + github.com/libp2p/go-libp2p-record v0.1.3 // indirect + github.com/libp2p/go-libp2p-routing-helpers v0.2.3 // indirect + github.com/libp2p/go-libp2p-swarm v0.5.3 // indirect + github.com/libp2p/go-libp2p-tls v0.2.0 // indirect + github.com/libp2p/go-libp2p-transport-upgrader v0.4.6 // indirect + github.com/libp2p/go-libp2p-xor v0.0.0-20210714161855-5c005aca55db // indirect + github.com/libp2p/go-libp2p-yamux v0.5.4 // indirect + github.com/libp2p/go-maddr-filter v0.1.0 // indirect + github.com/libp2p/go-mplex v0.3.0 // indirect + github.com/libp2p/go-msgio v0.0.6 // indirect + github.com/libp2p/go-nat v0.0.5 // indirect + github.com/libp2p/go-netroute v0.1.6 // indirect + github.com/libp2p/go-openssl v0.0.7 // indirect + github.com/libp2p/go-reuseport v0.0.2 // indirect + github.com/libp2p/go-reuseport-transport v0.0.5 // indirect + github.com/libp2p/go-sockaddr v0.1.1 // indirect + github.com/libp2p/go-stream-muxer-multistream v0.3.0 // indirect + github.com/libp2p/go-tcp-transport v0.2.8 // indirect + github.com/libp2p/go-ws-transport v0.5.0 // indirect + github.com/libp2p/go-yamux/v2 v2.2.0 // indirect + github.com/libp2p/zeroconf/v2 v2.0.0 // indirect + github.com/lucas-clemente/quic-go v0.23.0 // indirect + github.com/marten-seemann/qtls-go1-16 v0.1.4 // indirect + github.com/marten-seemann/qtls-go1-17 v0.1.0 // indirect + github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect + github.com/mattn/go-isatty v0.0.13 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/miekg/dns v1.1.43 // indirect + github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect + github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc // indirect + github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect + github.com/minio/sha256-simd v1.0.0 // indirect + github.com/mr-tron/base58 v1.2.0 // indirect + github.com/multiformats/go-base32 v0.0.3 // indirect + github.com/multiformats/go-base36 v0.1.0 // indirect + github.com/multiformats/go-multiaddr v0.4.0 // indirect + github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect + github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect + github.com/multiformats/go-multibase v0.0.3 // indirect + github.com/multiformats/go-multicodec v0.3.0 // indirect + github.com/multiformats/go-multihash v0.0.15 // indirect + github.com/multiformats/go-multistream v0.2.2 // indirect + github.com/multiformats/go-varint v0.0.6 // indirect + github.com/nxadm/tail v1.4.8 // indirect + github.com/onsi/ginkgo v1.16.4 // indirect + github.com/opentracing/opentracing-go v1.2.0 // indirect + github.com/polydawn/refmt v0.0.0-20201211092308-30ac6d18308e // indirect + github.com/prometheus/client_golang v1.11.0 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.30.0 // indirect + github.com/prometheus/procfs v0.7.3 // indirect + github.com/russross/blackfriday/v2 v2.0.1 // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect + github.com/spaolacci/murmur3 v1.1.0 // indirect + github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect + github.com/whyrusleeping/cbor-gen v0.0.0-20210219115102-f37d292932f2 // indirect + github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f // indirect + github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect + github.com/whyrusleeping/mdns v0.0.0-20190826153040-b9b60ed33aa9 // indirect + github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 // indirect + github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect + go.opencensus.io v0.23.0 // indirect + go.opentelemetry.io/otel v0.20.0 // indirect + go.opentelemetry.io/otel/metric v0.20.0 // indirect + go.opentelemetry.io/otel/trace v0.20.0 // indirect + go.uber.org/atomic v1.9.0 // indirect + go.uber.org/dig v1.10.0 // indirect + go.uber.org/fx v1.13.1 // indirect + go.uber.org/multierr v1.7.0 // indirect + go.uber.org/zap v1.19.0 // indirect + go4.org v0.0.0-20200411211856-f5505b9728dd // indirect + golang.org/x/crypto v0.0.0-20210813211128-0a44fdfbc16e // indirect + golang.org/x/mod v0.4.2 // indirect + golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect + golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect + golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912 // indirect + golang.org/x/tools v0.1.1 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + google.golang.org/protobuf v1.27.1 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect +) diff --git a/go.sum b/go.sum index 3b90473..435c1fd 100644 --- a/go.sum +++ b/go.sum @@ -144,7 +144,6 @@ github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7 github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -944,7 +943,6 @@ github.com/libp2p/go-yamux v1.3.3/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZ github.com/libp2p/go-yamux v1.3.5/go.mod h1:FGTiPvoV/3DVdgWpX+tM0OW3tsM+W5bSE3gZwqQTcow= github.com/libp2p/go-yamux v1.3.7/go.mod h1:fr7aVgmdNGJK+N1g+b6DW6VxzbRCjCOejR/hkmpooHE= github.com/libp2p/go-yamux v1.4.0/go.mod h1:fr7aVgmdNGJK+N1g+b6DW6VxzbRCjCOejR/hkmpooHE= -github.com/libp2p/go-yamux v1.4.1 h1:P1Fe9vF4th5JOxxgQvfbOHkrGqIZniTLf+ddhZp8YTI= github.com/libp2p/go-yamux v1.4.1/go.mod h1:fr7aVgmdNGJK+N1g+b6DW6VxzbRCjCOejR/hkmpooHE= github.com/libp2p/go-yamux/v2 v2.0.0/go.mod h1:NVWira5+sVUIU6tu1JWvaRn1dRnG+cawOJiflsAM+7U= github.com/libp2p/go-yamux/v2 v2.1.1/go.mod h1:3So6P6TV6r75R9jiBpiIKgU/66lOarCZjqROGxzPpPQ= @@ -1212,7 +1210,6 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= From 58d722c034fff97e5293009851b80282788f9c67 Mon Sep 17 00:00:00 2001 From: web3-bot Date: Wed, 23 Aug 2023 09:27:08 +0000 Subject: [PATCH 2/5] fix: stop using the deprecated io/ioutil package --- cli_test.go | 3 ++- config/util.go | 4 ++-- convert/checks_test.go | 15 +++++++-------- convert/convert.go | 7 +++---- convert/convert_test.go | 2 +- convert/copy.go | 5 ++--- convert/copy_test.go | 7 +++---- convert/prepare.go | 3 +-- revert/log.go | 4 ++-- revert/log_test.go | 9 ++++----- revert/revert.go | 4 ++-- revert/revert_test.go | 20 ++++++++++---------- revert/steps_test.go | 9 ++++----- strategy/strategy.go | 2 +- strategy/strategy_util.go | 2 +- testutil/repo.go | 5 ++--- 16 files changed, 47 insertions(+), 54 deletions(-) diff --git a/cli_test.go b/cli_test.go index d30768b..cc3570c 100644 --- a/cli_test.go +++ b/cli_test.go @@ -4,8 +4,9 @@ import ( "path" "testing" - "github.com/ipfs/ipfs-ds-convert/testutil" "os" + + "github.com/ipfs/ipfs-ds-convert/testutil" ) func TestBasicConvert(t *testing.T) { diff --git a/config/util.go b/config/util.go index 4c63bcd..93f933d 100644 --- a/config/util.go +++ b/config/util.go @@ -2,11 +2,11 @@ package config import ( "encoding/json" - "io/ioutil" + "os" ) func Load(path string, out *map[string]interface{}) error { - cfgbytes, err := ioutil.ReadFile(path) + cfgbytes, err := os.ReadFile(path) if err != nil { return err } diff --git a/convert/checks_test.go b/convert/checks_test.go index f6589c2..6801a56 100644 --- a/convert/checks_test.go +++ b/convert/checks_test.go @@ -2,7 +2,6 @@ package convert_test import ( "fmt" - "io/ioutil" "os" "path" "runtime" @@ -22,7 +21,7 @@ func TestInvalidRepoVersion(t *testing.T) { dir, _close, _, _ := testutil.PrepareTest(t, 10, 10) defer _close(t) - err := ioutil.WriteFile(path.Join(dir, "version"), []byte("147258369"), 0664) + err := os.WriteFile(path.Join(dir, "version"), []byte("147258369"), 0664) if err != nil { t.Fatal(err) } @@ -107,7 +106,7 @@ func TestInvalidVersion(t *testing.T) { dir, _close, _, _ := testutil.PrepareTest(t, 10, 10) defer _close(t) - err := ioutil.WriteFile(path.Join(dir, "version"), []byte("a"), 0600) + err := os.WriteFile(path.Join(dir, "version"), []byte("a"), 0600) if err != nil { t.Fatal(err) } @@ -128,7 +127,7 @@ func TestInvalidSpecJson(t *testing.T) { dir, _close, _, _ := testutil.PrepareTest(t, 10, 10) defer _close(t) - err := ioutil.WriteFile(path.Join(dir, repo.SpecsFile), []byte("}"), 0600) + err := os.WriteFile(path.Join(dir, repo.SpecsFile), []byte("}"), 0600) if err != nil { t.Fatal(err) } @@ -149,7 +148,7 @@ func TestInvalidSpecFile(t *testing.T) { dir, _close, _, _ := testutil.PrepareTest(t, 10, 10) defer _close(t) - err := ioutil.WriteFile(path.Join(dir, repo.SpecsFile), []byte("{}"), 0600) + err := os.WriteFile(path.Join(dir, repo.SpecsFile), []byte("{}"), 0600) if err != nil { t.Fatal(err) } @@ -191,7 +190,7 @@ func TestInvalidConfigJson(t *testing.T) { dir, _close, _, _ := testutil.PrepareTest(t, 10, 10) defer _close(t) - err := ioutil.WriteFile(path.Join(dir, repo.ConfigFile), []byte("}"), 0600) + err := os.WriteFile(path.Join(dir, repo.ConfigFile), []byte("}"), 0600) if err != nil { t.Fatal(err) } @@ -212,7 +211,7 @@ func TestInvalidConfigFile(t *testing.T) { dir, _close, _, _ := testutil.PrepareTest(t, 10, 10) defer _close(t) - err := ioutil.WriteFile(path.Join(dir, repo.ConfigFile), []byte("{}"), 0600) + err := os.WriteFile(path.Join(dir, repo.ConfigFile), []byte("{}"), 0600) if err != nil { t.Fatal(err) } @@ -231,7 +230,7 @@ func TestInvalidConfigFile(t *testing.T) { t.Fatal(err) } - err = ioutil.WriteFile(path.Join(dir, repo.ConfigFile), []byte(`{"Datastore":{}}`), 0600) + err = os.WriteFile(path.Join(dir, repo.ConfigFile), []byte(`{"Datastore":{}}`), 0600) if err != nil { t.Fatal(err) } diff --git a/convert/convert.go b/convert/convert.go index 3873acb..5de3afb 100644 --- a/convert/convert.go +++ b/convert/convert.go @@ -2,7 +2,6 @@ package convert import ( "fmt" - "io/ioutil" "os" "path/filepath" @@ -135,7 +134,7 @@ func (c *Conversion) saveNewSpec(backup bool) (err error) { return err } - err = ioutil.WriteFile(filepath.Join(c.path, repo.SpecsFile), []byte(toDiskId), 0660) + err = os.WriteFile(filepath.Join(c.path, repo.SpecsFile), []byte(toDiskId), 0660) if err != nil { return err } @@ -151,12 +150,12 @@ func (c *Conversion) saveNewSpec(backup bool) (err error) { } func (c *Conversion) backupSpec() error { - backupFile, err := ioutil.TempFile(c.path, "datastore_spec_backup") + backupFile, err := os.CreateTemp(c.path, "datastore_spec_backup") if err != nil { return err } - specData, err := ioutil.ReadFile(filepath.Join(c.path, repo.SpecsFile)) + specData, err := os.ReadFile(filepath.Join(c.path, repo.SpecsFile)) if err != nil { return err } diff --git a/convert/convert_test.go b/convert/convert_test.go index f5f7112..0c4fffd 100644 --- a/convert/convert_test.go +++ b/convert/convert_test.go @@ -47,7 +47,7 @@ func TestLossyConvert(t *testing.T) { t.Errorf("expected error 'adding missing to src spec: couldn't find best match for specA /'") } -//should cover noop case in convert.go +// should cover noop case in convert.go func TestNoopConvert(t *testing.T) { //Prepare repo dir, _close, s1, s2 := testutil.PrepareTest(t, 3000, 3000) diff --git a/convert/copy.go b/convert/copy.go index 85475e5..a186616 100644 --- a/convert/copy.go +++ b/convert/copy.go @@ -3,7 +3,6 @@ package convert import ( "fmt" "io" - "io/ioutil" "os" "path" "path/filepath" @@ -131,7 +130,7 @@ func (c *Copy) openDatastores() (err error) { } c.logStep("open datastore at %s", c.path) - c.newDsDir, err = ioutil.TempDir(c.path, "ds-convert") + c.newDsDir, err = os.MkdirTemp(c.path, "ds-convert") if err != nil { return errors.Wrapf(err, "error creating temp datastore at %s", c.path) } @@ -231,7 +230,7 @@ func CopyKeys(fromDs repo.Datastore, toDs repo.Datastore) error { } func (c *Copy) swapDatastores() (err error) { - c.oldDsDir, err = ioutil.TempDir(c.path, "ds-convert-old") + c.oldDsDir, err = os.MkdirTemp(c.path, "ds-convert-old") if err != nil { return errors.Wrapf(err, "error creating temp datastore at %s", c.path) } diff --git a/convert/copy_test.go b/convert/copy_test.go index 5e007d2..76e8fcf 100644 --- a/convert/copy_test.go +++ b/convert/copy_test.go @@ -2,7 +2,6 @@ package convert import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -57,7 +56,7 @@ var ( ) func TestInvalidSpecLeft(t *testing.T) { - d, err := ioutil.TempDir(os.TempDir(), "ds-convert-test-") + d, err := os.MkdirTemp(os.TempDir(), "ds-convert-test-") if err != nil { t.Fatalf(err.Error()) } @@ -76,7 +75,7 @@ func TestInvalidSpecLeft(t *testing.T) { } func TestInvalidSpecRight(t *testing.T) { - d, err := ioutil.TempDir(os.TempDir(), "ds-convert-test-") + d, err := os.MkdirTemp(os.TempDir(), "ds-convert-test-") if err != nil { t.Fatalf(err.Error()) } @@ -94,7 +93,7 @@ func TestInvalidSpecRight(t *testing.T) { } func TestOpenNonexist(t *testing.T) { - d, err := ioutil.TempDir(os.TempDir(), "ds-convert-test-") + d, err := os.MkdirTemp(os.TempDir(), "ds-convert-test-") if err != nil { t.Fatalf(err.Error()) } diff --git a/convert/prepare.go b/convert/prepare.go index 061e7cf..bc79b5f 100644 --- a/convert/prepare.go +++ b/convert/prepare.go @@ -2,7 +2,6 @@ package convert import ( "fmt" - "io/ioutil" "os" "path/filepath" "strconv" @@ -15,7 +14,7 @@ import ( ) func (c *Conversion) checkRepoVersion() error { - vstr, err := ioutil.ReadFile(filepath.Join(c.path, "version")) + vstr, err := os.ReadFile(filepath.Join(c.path, "version")) if err != nil { return err } diff --git a/revert/log.go b/revert/log.go index 7f68071..5a051a7 100644 --- a/revert/log.go +++ b/revert/log.go @@ -29,8 +29,8 @@ type ActionLogger struct { file *os.File } -//NewActionLogger creates revert action logger which logs actions needed to -//revert conversion steps +// NewActionLogger creates revert action logger which logs actions needed to +// revert conversion steps func NewActionLogger(repoPath string) (*ActionLogger, error) { if _, err := os.Stat(path.Join(repoPath, ConvertLog)); !os.IsNotExist(err) { return nil, fmt.Errorf("Log file %s already exists, you may want to run revert", path.Join(repoPath, ConvertLog)) diff --git a/revert/log_test.go b/revert/log_test.go index 3e65f83..4af285c 100644 --- a/revert/log_test.go +++ b/revert/log_test.go @@ -1,7 +1,6 @@ package revert_test import ( - "io/ioutil" "os" "path" "strings" @@ -11,12 +10,12 @@ import ( ) func TestNewActionLogger(t *testing.T) { - d, err := ioutil.TempDir(os.TempDir(), "ds-convert-test-") + d, err := os.MkdirTemp(os.TempDir(), "ds-convert-test-") if err != nil { t.Fatal(err) } - err = ioutil.WriteFile(path.Join(d, revert.ConvertLog), []byte{}, 0664) + err = os.WriteFile(path.Join(d, revert.ConvertLog), []byte{}, 0664) if err != nil { t.Fatal(err) } @@ -38,7 +37,7 @@ func TestNewActionLogger(t *testing.T) { } func TestLog(t *testing.T) { - d, err := ioutil.TempDir(os.TempDir(), "ds-convert-test-") + d, err := os.MkdirTemp(os.TempDir(), "ds-convert-test-") if err != nil { t.Fatal(err) } @@ -54,7 +53,7 @@ func TestLog(t *testing.T) { t.Fatal(err) } - b, err := ioutil.ReadFile(path.Join(d, revert.ConvertLog)) + b, err := os.ReadFile(path.Join(d, revert.ConvertLog)) if err != nil { t.Fatal(err) } diff --git a/revert/revert.go b/revert/revert.go index 42a361d..7cb9aef 100644 --- a/revert/revert.go +++ b/revert/revert.go @@ -10,10 +10,10 @@ import ( "github.com/ipfs/ipfs-ds-convert/repo" "encoding/json" + lock "github.com/ipfs/go-fs-lock" "github.com/ipfs/ipfs-ds-convert/config" "github.com/pkg/errors" - "io/ioutil" ) var Log = logging.New(os.Stderr, "revert ", logging.LstdFlags) @@ -222,7 +222,7 @@ func fixConfig(repoPath string) error { return err } - err = ioutil.WriteFile(filepath.Join(repoPath, repo.ConfigFile), []byte(confBytes), 0660) + err = os.WriteFile(filepath.Join(repoPath, repo.ConfigFile), []byte(confBytes), 0660) if err != nil { return err } diff --git a/revert/revert_test.go b/revert/revert_test.go index 3d64e94..b057764 100644 --- a/revert/revert_test.go +++ b/revert/revert_test.go @@ -1,7 +1,7 @@ package revert_test import ( - "io/ioutil" + "os" "path" "strings" "testing" @@ -136,7 +136,7 @@ func TestBasicConvertRevertUnknownStep(t *testing.T) { t.Fatal(err) } - ioutil.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"unknownactiontype","arg":[]}`), 0600) + os.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"unknownactiontype","arg":[]}`), 0600) err = revert.Revert(dir, true, false, false) if !strings.Contains(err.Error(), "unknown revert step 'unknownactiontype'") { @@ -176,35 +176,35 @@ func TestBasicConvertRevertInvalidArgs(t *testing.T) { t.Fatal(err) } - ioutil.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionRemove+`","arg":[]}`), 0600) + os.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionRemove+`","arg":[]}`), 0600) err = revert.Revert(dir, true, false, false) if !strings.Contains(err.Error(), "revert remove: arg count 0 != 1") { t.Fatal(err) } - ioutil.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionMove+`","arg":[]}`), 0600) + os.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionMove+`","arg":[]}`), 0600) err = revert.Revert(dir, true, false, false) if !strings.Contains(err.Error(), "revert move: arg count 0 != 2") { t.Fatal(err) } - ioutil.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionMkdir+`","arg":[]}`), 0600) + os.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionMkdir+`","arg":[]}`), 0600) err = revert.Revert(dir, true, false, false) if !strings.Contains(err.Error(), "revert mkdir: arg count 0 != 1") { t.Fatal(err) } - ioutil.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionCleanup+`","arg":["a"]}`), 0600) + os.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionCleanup+`","arg":["a"]}`), 0600) err = revert.Revert(dir, true, false, true) if !strings.Contains(err.Error(), "cannot cleanup after failed conversion") { t.Fatal(err) } - ioutil.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionCleanup+`","arg":[]}`+"\n"+`{"action":"`+revert.ActionDone+`","arg":[]}`), 0600) + os.WriteFile(path.Join(dir, revert.ConvertLog), []byte(`{"action":"`+revert.ActionCleanup+`","arg":[]}`+"\n"+`{"action":"`+revert.ActionDone+`","arg":[]}`), 0600) err = revert.Revert(dir, true, false, true) if !strings.Contains(err.Error(), "cleanup arg count 0 != 1") { @@ -222,7 +222,7 @@ func TestRevertMkdirChecks(t *testing.T) { t.Fatal(err) } - err = ioutil.WriteFile(path.Join(dir, revert.ConvertLog), []byte(l), 0600) + err = os.WriteFile(path.Join(dir, revert.ConvertLog), []byte(l), 0600) if err != nil { t.Fatal(err) } @@ -243,7 +243,7 @@ func TestRevertMoveChecks(t *testing.T) { t.Fatal(err) } - err = ioutil.WriteFile(path.Join(dir, revert.ConvertLog), []byte(l), 0600) + err = os.WriteFile(path.Join(dir, revert.ConvertLog), []byte(l), 0600) if err != nil { t.Fatal(err) } @@ -258,7 +258,7 @@ func TestRevertMoveChecks(t *testing.T) { t.Fatal(err) } - err = ioutil.WriteFile(path.Join(dir, revert.ConvertLog), []byte(l), 0600) + err = os.WriteFile(path.Join(dir, revert.ConvertLog), []byte(l), 0600) if err != nil { t.Fatal(err) } diff --git a/revert/steps_test.go b/revert/steps_test.go index 732b5da..4986dba 100644 --- a/revert/steps_test.go +++ b/revert/steps_test.go @@ -1,7 +1,6 @@ package revert import ( - "io/ioutil" "os" "path" "strings" @@ -16,22 +15,22 @@ func TestLoadNonexistentLog(t *testing.T) { } func TestLoadInvalidLog(t *testing.T) { - dname, _ := ioutil.TempDir(os.TempDir(), "ds-convert-test-") - _ = ioutil.WriteFile(path.Join(dname, ConvertLog), []byte("not a json\n"), 0600) + dname, _ := os.MkdirTemp(os.TempDir(), "ds-convert-test-") + _ = os.WriteFile(path.Join(dname, ConvertLog), []byte("not a json\n"), 0600) _, err := loadLog(dname) if !strings.Contains(err.Error(), "invalid character 'o' in literal null (expecting 'u')") { t.Errorf("unexpected error %s, expected invalid character...", err) } - _ = ioutil.WriteFile(path.Join(dname, ConvertLog), []byte(`{"action":5}`), 0600) + _ = os.WriteFile(path.Join(dname, ConvertLog), []byte(`{"action":5}`), 0600) _, err = loadLog(dname) if !strings.Contains(err.Error(), "invalid action type in convert steps") { t.Errorf("unexpected error %s, expected invalid action type in convert steps", err) } - _ = ioutil.WriteFile(path.Join(dname, ConvertLog), []byte(`{"action":"a","arg":[3]}`), 0600) + _ = os.WriteFile(path.Join(dname, ConvertLog), []byte(`{"action":"a","arg":[3]}`), 0600) _, err = loadLog(dname) if !strings.Contains(err.Error(), "invalid arg 0 in convert steps") { diff --git a/strategy/strategy.go b/strategy/strategy.go index ae59ed6..169ad92 100644 --- a/strategy/strategy.go +++ b/strategy/strategy.go @@ -22,7 +22,7 @@ var dsTypes = map[string]bool{ "badgerds": true, } -//datastors that have one directory inside IPFS repo +// datastors that have one directory inside IPFS repo var simpleTypes = map[string]bool{ "flatfs": true, "levelds": true, diff --git a/strategy/strategy_util.go b/strategy/strategy_util.go index ae3bfaf..e4d4e4c 100644 --- a/strategy/strategy_util.go +++ b/strategy/strategy_util.go @@ -65,7 +65,7 @@ func (m *SimpleMounts) hasMatching(searched SimpleMount) bool { return false } -//filter removes matching mounts from this mounts +// filter removes matching mounts from this mounts func (m *SimpleMounts) filter(filter SimpleMounts) SimpleMounts { out := make([]SimpleMount, 0, len(*m)) diff --git a/testutil/repo.go b/testutil/repo.go index d6fcd62..ff5487b 100644 --- a/testutil/repo.go +++ b/testutil/repo.go @@ -3,7 +3,6 @@ package testutil import ( "encoding/json" "fmt" - "io/ioutil" "os" "testing" @@ -46,7 +45,7 @@ func NewTestRepo(t *testing.T, spec map[string]interface{}) (string, func(t *tes conf.Datastore.Spec = spec } - repoRoot, err := ioutil.TempDir(os.TempDir(), "ds-convert-test-") + repoRoot, err := os.MkdirTemp(os.TempDir(), "ds-convert-test-") if err != nil { t.Fatal(err) } @@ -94,5 +93,5 @@ func PatchConfig(t *testing.T, configPath string, newSpecPath string) { if err != nil { t.Fatal(err) } - ioutil.WriteFile(configPath, b, 0660) + os.WriteFile(configPath, b, 0660) } From 98d02c1c2e09cf45e46779d1783da6c594d173c9 Mon Sep 17 00:00:00 2001 From: web3-bot Date: Wed, 13 Mar 2024 14:59:55 +0000 Subject: [PATCH 3/5] chore: bump go.mod to Go 1.21 and run go fix --- go.mod | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index fddde28..c4d1153 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,7 @@ module github.com/ipfs/ipfs-ds-convert -go 1.20 +go 1.21 + require ( github.com/ipfs/go-datastore v0.4.6 From 5d00236bc90f78850d460e9fe58efa91ddc80e87 Mon Sep 17 00:00:00 2001 From: web3-bot Date: Wed, 13 Mar 2024 14:59:56 +0000 Subject: [PATCH 4/5] chore: run go mod tidy --- go.mod | 1 - 1 file changed, 1 deletion(-) diff --git a/go.mod b/go.mod index c4d1153..a96705d 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,6 @@ module github.com/ipfs/ipfs-ds-convert go 1.21 - require ( github.com/ipfs/go-datastore v0.4.6 github.com/ipfs/go-ds-badger v0.2.7 From 5afcde0ddc99bb79e53af96cb0e073e07e6fabbb Mon Sep 17 00:00:00 2001 From: web3-bot Date: Fri, 23 Aug 2024 10:39:43 +0000 Subject: [PATCH 5/5] chore: bump go.mod to Go 1.22 and run go fix --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index a96705d..69853f4 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ipfs/ipfs-ds-convert -go 1.21 +go 1.22 require ( github.com/ipfs/go-datastore v0.4.6