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 ( ...@@ -5,7 +5,6 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath"
"reflect" "reflect"
carv2 "github.com/ipld/go-car/v2" carv2 "github.com/ipld/go-car/v2"
...@@ -69,12 +68,7 @@ func ExampleWriteTo() { ...@@ -69,12 +68,7 @@ func ExampleWriteTo() {
} }
// Store the index alone onto destination file. // Store the index alone onto destination file.
tdir, err := ioutil.TempDir(os.TempDir(), "example-*") f, err := ioutil.TempFile(os.TempDir(), "example-index-*.carindex")
if err != nil {
panic(err)
}
dst := filepath.Join(tdir, "index.carindex")
f, err := os.Create(dst)
if err != nil { if err != nil {
panic(err) 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