2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-25 06:07:44 +00:00

Don't shadow builtins

This commit is contained in:
Michael Eischer 2023-05-18 18:11:26 +02:00
parent 7a01bd3b67
commit 2fa8b96843
3 changed files with 11 additions and 11 deletions

View File

@ -93,12 +93,12 @@ func TestListAPI(t *testing.T) {
// stat file in data/, use the first two bytes in the name // stat file in data/, use the first two bytes in the name
// of the file as the size :) // of the file as the size :)
filename := req.URL.Path[6:] filename := req.URL.Path[6:]
len, err := strconv.ParseInt(filename[:4], 16, 64) length, err := strconv.ParseInt(filename[:4], 16, 64)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
res.Header().Set("Content-Length", fmt.Sprintf("%d", len)) res.Header().Set("Content-Length", fmt.Sprintf("%d", length))
res.WriteHeader(http.StatusOK) res.WriteHeader(http.StatusOK)
return return
} }

View File

@ -68,21 +68,21 @@ func extractToFile(buf []byte, filename, target string, printf func(string, ...i
// Write everything to a temp file // Write everything to a temp file
dir := filepath.Dir(target) dir := filepath.Dir(target)
new, err := os.CreateTemp(dir, "restic") newFile, err := os.CreateTemp(dir, "restic")
if err != nil { if err != nil {
return err return err
} }
n, err := io.Copy(new, rd) n, err := io.Copy(newFile, rd)
if err != nil { if err != nil {
_ = new.Close() _ = newFile.Close()
_ = os.Remove(new.Name()) _ = os.Remove(newFile.Name())
return err return err
} }
if err = new.Sync(); err != nil { if err = newFile.Sync(); err != nil {
return err return err
} }
if err = new.Close(); err != nil { if err = newFile.Close(); err != nil {
return err return err
} }
@ -98,7 +98,7 @@ func extractToFile(buf []byte, filename, target string, printf func(string, ...i
} }
// Rename the temp file to the final location atomically. // Rename the temp file to the final location atomically.
if err := os.Rename(new.Name(), target); err != nil { if err := os.Rename(newFile.Name(), target); err != nil {
return err return err
} }

View File

@ -177,10 +177,10 @@ func (t *Table) Write(w io.Writer) error {
// write all the lines // write all the lines
for i, line := range lines { for i, line := range lines {
print := func(w io.Writer, s string) error { printer := func(w io.Writer, s string) error {
return t.PrintData(w, i, s) return t.PrintData(w, i, s)
} }
err := printLine(w, print, t.CellSeparator, line, columnWidths) err := printLine(w, printer, t.CellSeparator, line, columnWidths)
if err != nil { if err != nil {
return err return err
} }