From 326783fe5b60a7e80510fb3267ca08d13343b559 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Tue, 20 Jul 2021 17:36:44 +0100 Subject: [PATCH] Use `ioutil.TempFile` to simplify file creation in index example Use existing SDK to create temp file in index example. --- v2/index/example_test.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/v2/index/example_test.go b/v2/index/example_test.go index 5070462..ca0ac73 100644 --- a/v2/index/example_test.go +++ b/v2/index/example_test.go @@ -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) } -- GitLab