Commit 326783fe authored by Masih H. Derkani's avatar Masih H. Derkani Committed by Masih H. Derkani

Use `ioutil.TempFile` to simplify file creation in index example

Use existing SDK to create temp file in index example.
parent c3a59556
......@@ -5,7 +5,6 @@ import (
"io"
"io/ioutil"
"os"
"path/filepath"
"reflect"
carv2 "github.com/ipld/go-car/v2"
......@@ -69,12 +68,7 @@ func ExampleWriteTo() {
}
// Store the index alone onto destination file.
tdir, err := ioutil.TempDir(os.TempDir(), "example-*")
if err != nil {
panic(err)
}
dst := filepath.Join(tdir, "index.carindex")
f, err := os.Create(dst)
f, err := ioutil.TempFile(os.TempDir(), "example-index-*.carindex")
if err != nil {
panic(err)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment