Skip to content

Commit

Permalink
fix: actually use the size hint in util_windows.go
Browse files Browse the repository at this point in the history
This code was broken, it computed the size hint to do nothing with it.
  • Loading branch information
Jorropo committed Oct 15, 2023
1 parent fa30377 commit 635dbac
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions util_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,15 @@ func readFileOnce(filename string) ([]byte, error) {
// cheaply. If the size was wrong, we'll either waste some space off the end
// or reallocate as needed, but in the overwhelmingly common case we'll get
// it just right.
if size := fi.Size() + bytes.MinRead; size > n {
n = size
}
n += fi.Size()
}

var buf bytes.Buffer
buf.Grow(n)

Check failure on line 99 in util_windows.go

View workflow job for this annotation

GitHub Actions / go-test / windows (go next)

cannot use n (variable of type int64) as int value in argument to buf.Grow
_, err := io.Copy(&buf, f)

Check failure on line 100 in util_windows.go

View workflow job for this annotation

GitHub Actions / go-test / windows (go next)

no new variables on left side of :=
if err != nil {
return nil, err
}

return io.ReadAll(f)
return buf.Bytes(), nil
}

0 comments on commit 635dbac

Please sign in to comment.