diff --git a/.github/workflows/go-check.yml b/.github/workflows/go-check.yml index 25e1afde5..251f7faa9 100644 --- a/.github/workflows/go-check.yml +++ b/.github/workflows/go-check.yml @@ -11,12 +11,12 @@ jobs: env: RUNGOGENERATE: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v3 with: - go-version: "1.18.x" + go-version: "1.19.x" - name: Run repo-specific setup uses: ./.github/actions/go-check-setup if: hashFiles('./.github/actions/go-check-setup') != '' @@ -27,7 +27,7 @@ jobs: echo "RUNGOGENERATE=true" >> $GITHUB_ENV fi - name: Install staticcheck - run: go install honnef.co/go/tools/cmd/staticcheck@d7e217c1ff411395475b2971c0824e1e7cc1af98 # 2022.1 (v0.3.0) + run: go install honnef.co/go/tools/cmd/staticcheck@376210a89477dedbe6fdc4484b233998650d7b3c # 2022.1.3 (v0.3.3) - name: Check that go.mod is tidy uses: protocol/multiple-go-modules@v1.2 with: diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index b86241a96..8a1697b2d 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -10,16 +10,16 @@ jobs: fail-fast: false matrix: os: [ "ubuntu", "windows", "macos" ] - go: [ "1.17.x", "1.18.x" ] + go: [ "1.18.x", "1.19.x" ] env: COVERAGES: "" runs-on: ${{ format('{0}-latest', matrix.os) }} name: ${{ matrix.os }} (go ${{ matrix.go }}) steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v3 with: go-version: ${{ matrix.go }} - name: Go information @@ -43,7 +43,7 @@ jobs: # Use -coverpkg=./..., so that we include cross-package coverage. # If package ./A imports ./B, and ./A's tests also cover ./B, # this means ./B's coverage will be significantly higher than 0%. - run: go test -v -coverprofile=module-coverage.txt -coverpkg=./... ./... + run: go test -v -shuffle=on -coverprofile=module-coverage.txt -coverpkg=./... ./... - name: Run tests (32 bit) if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX. uses: protocol/multiple-go-modules@v1.2 @@ -52,7 +52,7 @@ jobs: with: run: | export "PATH=${{ env.PATH_386 }}:$PATH" - go test -v ./... + go test -v -shuffle=on ./... - name: Run tests with race detector if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow uses: protocol/multiple-go-modules@v1.2 @@ -62,7 +62,7 @@ jobs: shell: bash run: echo "COVERAGES=$(find . -type f -name 'module-coverage.txt' | tr -s '\n' ',' | sed 's/,$//')" >> $GITHUB_ENV - name: Upload coverage to Codecov - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 # v3.1.0 with: files: '${{ env.COVERAGES }}' env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }} diff --git a/go.mod b/go.mod index 020962a88..3ac2b3820 100644 --- a/go.mod +++ b/go.mod @@ -63,4 +63,4 @@ require ( gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) -go 1.17 +go 1.18 diff --git a/hamt/hamt.go b/hamt/hamt.go index 593b64627..d9947770f 100644 --- a/hamt/hamt.go +++ b/hamt/hamt.go @@ -9,8 +9,10 @@ // wikipedia article is the collapsing of empty shards. // Given the following tree: ( '[' = shards, '{' = values ) // [ 'A' ] -> [ 'B' ] -> { "ABC" } -// | L-> { "ABD" } -// L-> { "ASDF" } +// +// | L-> { "ABD" } +// L-> { "ASDF" } +// // If we simply removed "ABC", we would end up with a tree where shard 'B' only // has a single child. This causes two issues, the first, is that now we have // an extra lookup required to get to "ABD". The second issue is that now we @@ -460,11 +462,11 @@ func (ds *Shard) walkChildren(processLinkValues func(formattedLink *ipld.Link) e // parallelShardWalk is quite similar to the DAG walking algorithm from https://github.com/ipfs/go-merkledag/blob/594e515f162e764183243b72c2ba84f743424c8c/merkledag.go#L464 // However, there are a few notable differences: -// 1. Some children are actualized Shard structs and some are in the blockstore, this will leverage walking over the in memory Shards as well as the stored blocks -// 2. Instead of just passing each child into the worker pool by itself we group them so that we can leverage optimizations from GetMany. -// This optimization also makes the walk a little more biased towards depth (as opposed to BFS) in the earlier part of the DAG. -// This is particularly helpful for operations like estimating the directory size which should complete quickly when possible. -// 3. None of the extra options from that package are needed +// 1. Some children are actualized Shard structs and some are in the blockstore, this will leverage walking over the in memory Shards as well as the stored blocks +// 2. Instead of just passing each child into the worker pool by itself we group them so that we can leverage optimizations from GetMany. +// This optimization also makes the walk a little more biased towards depth (as opposed to BFS) in the earlier part of the DAG. +// This is particularly helpful for operations like estimating the directory size which should complete quickly when possible. +// 3. None of the extra options from that package are needed func parallelShardWalk(ctx context.Context, root *Shard, dserv ipld.DAGService, processShardValues func(formattedLink *ipld.Link) error) error { const concurrency = 32 diff --git a/importer/balanced/balanced_test.go b/importer/balanced/balanced_test.go index b2069e3a9..bfb348ed9 100644 --- a/importer/balanced/balanced_test.go +++ b/importer/balanced/balanced_test.go @@ -5,7 +5,6 @@ import ( "context" "fmt" "io" - "io/ioutil" mrand "math/rand" "testing" @@ -53,7 +52,7 @@ func getTestDag(t *testing.T, ds ipld.DAGService, size int64, blksize int64) (*d return nd, data } -//Test where calls to read are smaller than the chunk size +// Test where calls to read are smaller than the chunk size func TestSizeBasedSplit(t *testing.T) { if testing.Short() { t.SkipNow() @@ -119,7 +118,7 @@ func arrComp(a, b []byte) error { } func dagrArrComp(t *testing.T, r io.Reader, should []byte) { - out, err := ioutil.ReadAll(r) + out, err := io.ReadAll(r) if err != nil { t.Fatal(err) } @@ -138,7 +137,7 @@ func TestIndirectBlocks(t *testing.T) { t.Fatal(err) } - out, err := ioutil.ReadAll(reader) + out, err := io.ReadAll(reader) if err != nil { t.Fatal(err) } @@ -179,7 +178,7 @@ func TestSeekToBegin(t *testing.T) { t.Fatal(err) } - n, err := io.CopyN(ioutil.Discard, rs, 1024*4) + n, err := io.CopyN(io.Discard, rs, 1024*4) if err != nil { t.Fatal(err) } @@ -207,7 +206,7 @@ func TestSeekToAlmostBegin(t *testing.T) { t.Fatal(err) } - n, err := io.CopyN(ioutil.Discard, rs, 1024*4) + n, err := io.CopyN(io.Discard, rs, 1024*4) if err != nil { t.Fatal(err) } diff --git a/importer/balanced/builder.go b/importer/balanced/builder.go index 407117dad..3379e9765 100644 --- a/importer/balanced/builder.go +++ b/importer/balanced/builder.go @@ -17,36 +17,37 @@ // that the UnixFS node. // // Notes: -// 1. In the implementation. `FSNodeOverDag` structure is used for representing -// the UnixFS node encoded inside the DAG node. -// (see https://github.com/ipfs/go-ipfs/pull/5118.) -// 2. `TFile` is used for backwards-compatibility. It was a bug causing the leaf -// nodes to be generated with this type instead of `TRaw`. The former one -// should be used (like the trickle builder does). -// (See https://github.com/ipfs/go-ipfs/pull/5120.) // -// +-------------+ -// | Root 4 | -// +-------------+ -// | -// +--------------------------+----------------------------+ -// | | -// +-------------+ +-------------+ -// | Node 2 | | Node 5 | -// +-------------+ +-------------+ -// | | -// +-------------+-------------+ +-------------+ -// | | | -// +-------------+ +-------------+ +-------------+ -// | Node 1 | | Node 3 | | Node 6 | -// +-------------+ +-------------+ +-------------+ -// | | | -// +------+------+ +------+------+ +------+ -// | | | | | -// +=========+ +=========+ +=========+ +=========+ +=========+ -// | Chunk 1 | | Chunk 2 | | Chunk 3 | | Chunk 4 | | Chunk 5 | -// +=========+ +=========+ +=========+ +=========+ +=========+ +// 1. In the implementation. `FSNodeOverDag` structure is used for representing +// the UnixFS node encoded inside the DAG node. +// (see https://github.com/ipfs/go-ipfs/pull/5118.) // +// 2. `TFile` is used for backwards-compatibility. It was a bug causing the leaf +// nodes to be generated with this type instead of `TRaw`. The former one +// should be used (like the trickle builder does). +// (See https://github.com/ipfs/go-ipfs/pull/5120.) +// +// +-------------+ +// | Root 4 | +// +-------------+ +// | +// +--------------------------+----------------------------+ +// | | +// +-------------+ +-------------+ +// | Node 2 | | Node 5 | +// +-------------+ +-------------+ +// | | +// +-------------+-------------+ +-------------+ +// | | | +// +-------------+ +-------------+ +-------------+ +// | Node 1 | | Node 3 | | Node 6 | +// +-------------+ +-------------+ +-------------+ +// | | | +// +------+------+ +------+------+ +------+ +// | | | | | +// +=========+ +=========+ +=========+ +=========+ +=========+ +// | Chunk 1 | | Chunk 2 | | Chunk 3 | | Chunk 4 | | Chunk 5 | +// +=========+ +=========+ +=========+ +=========+ +=========+ package balanced import ( @@ -80,55 +81,54 @@ import ( // offset in the file the graph represents: each internal node uses the file size // of its children as an index when seeking. // -// `Layout` creates a root and hands it off to be filled: -// -// +-------------+ -// | Root 1 | -// +-------------+ -// | -// ( fillNodeRec fills in the ) -// ( chunks on the root. ) -// | -// +------+------+ -// | | -// + - - - - + + - - - - + -// | Chunk 1 | | Chunk 2 | -// + - - - - + + - - - - + +// `Layout` creates a root and hands it off to be filled: // -// ↓ -// When the root is full but there's more data... -// ↓ +// +-------------+ +// | Root 1 | +// +-------------+ +// | +// ( fillNodeRec fills in the ) +// ( chunks on the root. ) +// | +// +------+------+ +// | | +// + - - - - + + - - - - + +// | Chunk 1 | | Chunk 2 | +// + - - - - + + - - - - + // -// +-------------+ -// | Root 1 | -// +-------------+ -// | -// +------+------+ -// | | -// +=========+ +=========+ + - - - - + -// | Chunk 1 | | Chunk 2 | | Chunk 3 | -// +=========+ +=========+ + - - - - + +// ↓ +// When the root is full but there's more data... +// ↓ // -// ↓ -// ...Layout's job is to create a new root. -// ↓ +// +-------------+ +// | Root 1 | +// +-------------+ +// | +// +------+------+ +// | | +// +=========+ +=========+ + - - - - + +// | Chunk 1 | | Chunk 2 | | Chunk 3 | +// +=========+ +=========+ + - - - - + // -// +-------------+ -// | Root 2 | -// +-------------+ -// | -// +-------------+ - - - - - - - - + -// | | -// +-------------+ ( fillNodeRec creates the ) -// | Node 1 | ( branch that connects ) -// +-------------+ ( "Root 2" to "Chunk 3." ) -// | | -// +------+------+ + - - - - -+ -// | | | -// +=========+ +=========+ + - - - - + -// | Chunk 1 | | Chunk 2 | | Chunk 3 | -// +=========+ +=========+ + - - - - + +// ↓ +// ...Layout's job is to create a new root. +// ↓ // +// +-------------+ +// | Root 2 | +// +-------------+ +// | +// +-------------+ - - - - - - - - + +// | | +// +-------------+ ( fillNodeRec creates the ) +// | Node 1 | ( branch that connects ) +// +-------------+ ( "Root 2" to "Chunk 3." ) +// | | +// +------+------+ + - - - - -+ +// | | | +// +=========+ +=========+ + - - - - + +// | Chunk 1 | | Chunk 2 | | Chunk 3 | +// +=========+ +=========+ + - - - - + func Layout(db *h.DagBuilderHelper) (ipld.Node, error) { if db.Done() { // No data, return just an empty node. @@ -185,22 +185,22 @@ func Layout(db *h.DagBuilderHelper) (ipld.Node, error) { // root, and those children will in turn be filled (calling `fillNodeRec` // recursively). // -// +-------------+ -// | `node` | -// | (new root) | -// +-------------+ -// | -// +-------------+ - - - - - - + - - - - - - - - - - - + -// | | | -// +--------------+ + - - - - - + + - - - - - + -// | (old root) | | new child | | | -// +--------------+ + - - - - - + + - - - - - + -// | | | -// +------+------+ + - - + - - - + -// | | | | -// +=========+ +=========+ + - - - - + + - - - - + -// | Chunk 1 | | Chunk 2 | | Chunk 3 | | Chunk 4 | -// +=========+ +=========+ + - - - - + + - - - - + +// +-------------+ +// | `node` | +// | (new root) | +// +-------------+ +// | +// +-------------+ - - - - - - + - - - - - - - - - - - + +// | | | +// +--------------+ + - - - - - + + - - - - - + +// | (old root) | | new child | | | +// +--------------+ + - - - - - + + - - - - - + +// | | | +// +------+------+ + - - + - - - + +// | | | | +// +=========+ +=========+ + - - - - + + - - - - + +// | Chunk 1 | | Chunk 2 | | Chunk 3 | | Chunk 4 | +// +=========+ +=========+ + - - - - + + - - - - + // // The `node` to be filled uses the `FSNodeOverDag` abstraction that allows adding // child nodes without packing/unpacking the UnixFS layer node (having an internal diff --git a/importer/helpers/helpers.go b/importer/helpers/helpers.go index 075b2d2d2..20cb598e6 100644 --- a/importer/helpers/helpers.go +++ b/importer/helpers/helpers.go @@ -13,17 +13,18 @@ var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name + protobuf // DefaultLinksPerBlock governs how the importer decides how many links there // will be per block. This calculation is based on expected distributions of: -// * the expected distribution of block sizes -// * the expected distribution of link sizes -// * desired access speed +// - the expected distribution of block sizes +// - the expected distribution of link sizes +// - desired access speed +// // For now, we use: // -// var roughLinkBlockSize = 1 << 13 // 8KB -// var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name -// // + protobuf framing -// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize) -// = ( 8192 / 47 ) -// = (approximately) 174 +// var roughLinkBlockSize = 1 << 13 // 8KB +// var roughLinkSize = 34 + 8 + 5 // sha256 multihash + size + no name +// // + protobuf framing +// var DefaultLinksPerBlock = (roughLinkBlockSize / roughLinkSize) +// = ( 8192 / 47 ) +// = (approximately) 174 var DefaultLinksPerBlock = roughLinkBlockSize / roughLinkSize // ErrSizeLimitExceeded signals that a block is larger than BlockSizeLimit. diff --git a/importer/importer_test.go b/importer/importer_test.go index b39aff57d..96732be20 100644 --- a/importer/importer_test.go +++ b/importer/importer_test.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "io" - "io/ioutil" "testing" uio "github.com/ipfs/go-unixfs/io" @@ -60,7 +59,7 @@ func TestStableCid(t *testing.T) { t.Fatal(err) } - out, err := ioutil.ReadAll(dr) + out, err := io.ReadAll(dr) if err != nil { t.Fatal(err) } @@ -86,7 +85,7 @@ func TestBalancedDag(t *testing.T) { t.Fatal(err) } - out, err := ioutil.ReadAll(dr) + out, err := io.ReadAll(dr) if err != nil { t.Fatal(err) } @@ -144,7 +143,7 @@ func runReadBench(b *testing.B, nd ipld.Node, ds ipld.DAGService) { b.Fatal(err) } - _, err = read.WriteTo(ioutil.Discard) + _, err = read.WriteTo(io.Discard) if err != nil && err != io.EOF { b.Fatal(err) } diff --git a/importer/trickle/trickle_test.go b/importer/trickle/trickle_test.go index 2b6e0bd46..5965a490a 100644 --- a/importer/trickle/trickle_test.go +++ b/importer/trickle/trickle_test.go @@ -5,7 +5,6 @@ import ( "context" "fmt" "io" - "io/ioutil" mrand "math/rand" "testing" @@ -62,7 +61,7 @@ func buildTestDag(ds ipld.DAGService, spl chunker.Splitter, rawLeaves UseRawLeav }) } -//Test where calls to read are smaller than the chunk size +// Test where calls to read are smaller than the chunk size func TestSizeBasedSplit(t *testing.T) { runBothSubtests(t, testSizeBasedSplit) } @@ -103,7 +102,7 @@ func testFileConsistency(t *testing.T, bs chunker.SplitterGen, nbytes int, rawLe t.Fatal(err) } - out, err := ioutil.ReadAll(r) + out, err := io.ReadAll(r) if err != nil { t.Fatal(err) } @@ -133,7 +132,7 @@ func testBuilderConsistency(t *testing.T, rawLeaves UseRawLeaves) { t.Fatal(err) } - out, err := ioutil.ReadAll(r) + out, err := io.ReadAll(r) if err != nil { t.Fatal(err) } @@ -179,7 +178,7 @@ func testIndirectBlocks(t *testing.T, rawLeaves UseRawLeaves) { t.Fatal(err) } - out, err := ioutil.ReadAll(reader) + out, err := io.ReadAll(reader) if err != nil { t.Fatal(err) } @@ -219,7 +218,7 @@ func testSeekingBasic(t *testing.T, rawLeaves UseRawLeaves) { t.Fatal("Failed to seek to correct offset") } - out, err := ioutil.ReadAll(rs) + out, err := io.ReadAll(rs) if err != nil { t.Fatal(err) } @@ -251,7 +250,7 @@ func testSeekToBegin(t *testing.T, rawLeaves UseRawLeaves) { t.Fatal(err) } - n, err := io.CopyN(ioutil.Discard, rs, 1024*4) + n, err := io.CopyN(io.Discard, rs, 1024*4) if err != nil { t.Fatal(err) } @@ -267,7 +266,7 @@ func testSeekToBegin(t *testing.T, rawLeaves UseRawLeaves) { t.Fatal("Failed to seek to beginning") } - out, err := ioutil.ReadAll(rs) + out, err := io.ReadAll(rs) if err != nil { t.Fatal(err) } @@ -299,7 +298,7 @@ func testSeekToAlmostBegin(t *testing.T, rawLeaves UseRawLeaves) { t.Fatal(err) } - n, err := io.CopyN(ioutil.Discard, rs, 1024*4) + n, err := io.CopyN(io.Discard, rs, 1024*4) if err != nil { t.Fatal(err) } @@ -315,7 +314,7 @@ func testSeekToAlmostBegin(t *testing.T, rawLeaves UseRawLeaves) { t.Fatal("Failed to seek to almost beginning") } - out, err := ioutil.ReadAll(rs) + out, err := io.ReadAll(rs) if err != nil { t.Fatal(err) } @@ -534,7 +533,7 @@ func testAppend(t *testing.T, rawLeaves UseRawLeaves) { t.Fatal(err) } - out, err := ioutil.ReadAll(fread) + out, err := io.ReadAll(fread) if err != nil { t.Fatal(err) } @@ -600,7 +599,7 @@ func testMultipleAppends(t *testing.T, rawLeaves UseRawLeaves) { t.Fatal(err) } - out, err := ioutil.ReadAll(fread) + out, err := io.ReadAll(fread) if err != nil { t.Fatal(err) } @@ -654,7 +653,7 @@ func TestAppendSingleBytesToEmpty(t *testing.T) { t.Fatal(err) } - out, err := ioutil.ReadAll(fread) + out, err := io.ReadAll(fread) if err != nil { t.Fatal(err) } diff --git a/io/completehamt_test.go b/io/completehamt_test.go index 2af652e32..9be35d8ad 100644 --- a/io/completehamt_test.go +++ b/io/completehamt_test.go @@ -4,10 +4,11 @@ import ( "context" "encoding/binary" "fmt" - "github.com/ipfs/go-unixfs/internal" "math" "testing" + "github.com/ipfs/go-unixfs/internal" + mdtest "github.com/ipfs/go-merkledag/test" "github.com/stretchr/testify/assert" @@ -18,14 +19,16 @@ import ( ) // CreateCompleteHAMT creates a HAMT the following properties: -// * its height (distance/edges from root to deepest node) is specified by treeHeight. -// * all leaf Shard nodes have the same depth (and have only 'value' links). -// * all internal Shard nodes point only to other Shards (and hence have zero 'value' links). -// * the total number of 'value' links (directory entries) is: -// childsPerNode ^ (treeHeight). -// treeHeight: The number of layers of non-value HAMT nodes (e.g. height = 1 is a single shard pointing to some values) +// - its height (distance/edges from root to deepest node) is specified by treeHeight. +// - all leaf Shard nodes have the same depth (and have only 'value' links). +// - all internal Shard nodes point only to other Shards (and hence have zero 'value' links). +// - the total number of 'value' links (directory entries) is: +// childsPerNode ^ (treeHeight). +// treeHeight: The number of layers of non-value HAMT nodes (e.g. height = 1 is a single shard pointing to some values) +// // FIXME: HAMTHashFunction needs to be set to idHash by the caller. We depend on -// this simplification for the current logic to work. +// +// this simplification for the current logic to work. func CreateCompleteHAMT(ds ipld.DAGService, treeHeight int, childsPerNode int) (ipld.Node, error) { if treeHeight < 1 { panic("treeHeight < 1") @@ -75,7 +78,8 @@ func idHash(val []byte) []byte { } // FIXME: This is not checking the exact height of the tree but just making -// sure there are as many children as we would have with a complete HAMT. +// +// sure there are as many children as we would have with a complete HAMT. func TestCreateCompleteShard(t *testing.T) { oldHashFunc := internal.HAMTHashFunction defer func() { internal.HAMTHashFunction = oldHashFunc }() diff --git a/io/dagreader_test.go b/io/dagreader_test.go index de664370c..1ec3225bb 100644 --- a/io/dagreader_test.go +++ b/io/dagreader_test.go @@ -3,7 +3,6 @@ package io import ( "bytes" "io" - "io/ioutil" "strings" "testing" @@ -26,7 +25,7 @@ func TestBasicRead(t *testing.T) { t.Fatal(err) } - outbuf, err := ioutil.ReadAll(reader) + outbuf, err := io.ReadAll(reader) if err != nil { t.Fatal(err) } @@ -257,7 +256,7 @@ func TestMetadataNode(t *testing.T) { if err != nil { t.Fatal(err) } - readdata, err := ioutil.ReadAll(reader) + readdata, err := io.ReadAll(reader) if err != nil { t.Fatal(err) } diff --git a/mod/dagmodifier_test.go b/mod/dagmodifier_test.go index 9870b2022..a37590679 100644 --- a/mod/dagmodifier_test.go +++ b/mod/dagmodifier_test.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "testing" dag "github.com/ipfs/go-merkledag" @@ -63,7 +62,7 @@ func verifyNode(t *testing.T, orig []byte, dm *DagModifier, opts testu.NodeOpts) t.Fatal(err) } - after, err := ioutil.ReadAll(rd) + after, err := io.ReadAll(rd) if err != nil { t.Fatal(err) } @@ -329,7 +328,7 @@ func testLargeWriteChunks(t *testing.T, opts testu.NodeOpts) { t.Fatal(err) } - out, err := ioutil.ReadAll(dagmod) + out, err := io.ReadAll(dagmod) if err != nil { t.Fatal(err) } @@ -374,7 +373,7 @@ func testDagTruncate(t *testing.T, opts testu.NodeOpts) { t.Fatal(err) } - out, err := ioutil.ReadAll(dagmod) + out, err := io.ReadAll(dagmod) if err != nil { t.Fatal(err) } @@ -458,7 +457,7 @@ func TestDagSync(t *testing.T) { t.Fatal(err) } - out, err := ioutil.ReadAll(dagmod) + out, err := io.ReadAll(dagmod) if err != nil { t.Fatal(err) } @@ -540,7 +539,7 @@ func testSparseWrite(t *testing.T, opts testu.NodeOpts) { t.Fatal(err) } - out, err := ioutil.ReadAll(dagmod) + out, err := io.ReadAll(dagmod) if err != nil { t.Fatal(err) } @@ -593,7 +592,7 @@ func testSeekPastEndWrite(t *testing.T, opts testu.NodeOpts) { t.Fatal(err) } - out, err := ioutil.ReadAll(dagmod) + out, err := io.ReadAll(dagmod) if err != nil { t.Fatal(err) } @@ -627,7 +626,7 @@ func testRelativeSeek(t *testing.T, opts testu.NodeOpts) { } } - out, err := ioutil.ReadAll(dagmod) + out, err := io.ReadAll(dagmod) if err != nil { t.Fatal(err) } diff --git a/pb/unixfs.pb.go b/pb/unixfs.pb.go index 6f1c8fe83..e52314007 100644 --- a/pb/unixfs.pb.go +++ b/pb/unixfs.pb.go @@ -5,8 +5,9 @@ package unixfs_pb import ( fmt "fmt" - proto "github.com/gogo/protobuf/proto" math "math" + + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/test/utils.go b/test/utils.go index bb251bc11..b30f43c21 100644 --- a/test/utils.go +++ b/test/utils.go @@ -5,7 +5,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "testing" ft "github.com/ipfs/go-unixfs" @@ -87,7 +86,7 @@ func GetEmptyNode(t testing.TB, dserv ipld.DAGService, opts NodeOpts) ipld.Node // GetRandomNode returns a random unixfs file node. func GetRandomNode(t testing.TB, dserv ipld.DAGService, size int64, opts NodeOpts) ([]byte, ipld.Node) { in := io.LimitReader(u.NewTimeSeededRand(), size) - buf, err := ioutil.ReadAll(in) + buf, err := io.ReadAll(in) if err != nil { t.Fatal(err) } diff --git a/unixfs.go b/unixfs.go index 026b8bb3f..cd3481ea4 100644 --- a/unixfs.go +++ b/unixfs.go @@ -69,7 +69,7 @@ func FilePBData(data []byte, totalsize uint64) []byte { return data } -//FolderPBData returns Bytes that represent a Directory. +// FolderPBData returns Bytes that represent a Directory. func FolderPBData() []byte { pbfile := new(pb.Data) typ := pb.Data_Directory @@ -83,7 +83,7 @@ func FolderPBData() []byte { return data } -//WrapData marshals raw bytes into a `Data_Raw` type protobuf message. +// WrapData marshals raw bytes into a `Data_Raw` type protobuf message. func WrapData(b []byte) []byte { pbdata := new(pb.Data) typ := pb.Data_Raw @@ -100,7 +100,7 @@ func WrapData(b []byte) []byte { return out } -//SymlinkData returns a `Data_Symlink` protobuf message for the path you specify. +// SymlinkData returns a `Data_Symlink` protobuf message for the path you specify. func SymlinkData(path string) ([]byte, error) { pbdata := new(pb.Data) typ := pb.Data_Symlink