mirror of
https://github.com/vbatts/tar-split.git
synced 2025-07-30 02:40:27 +00:00
*.go: linting project specific code
the pointer to the pool may be useful, but holding on that until I get benchmarks of memory use to show the benefit. Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
19fa6f3d1e
commit
516158dbfb
4 changed files with 28 additions and 16 deletions
|
@ -71,6 +71,8 @@ func WriteOutputTarStream(fg storage.FileGetter, up storage.Unpacker, w io.Write
|
|||
crcSum = make([]byte, 8)
|
||||
multiWriter = io.MultiWriter(w, crcHash)
|
||||
copyBuffer = byteBufferPool.Get().([]byte)
|
||||
// TODO once we have some benchmark or memory profile then we can experiment with using *bytes.Buffer
|
||||
//nolint:staticcheck // SA6002 not going to do a pointer here
|
||||
defer byteBufferPool.Put(copyBuffer)
|
||||
} else {
|
||||
crcHash.Reset()
|
||||
|
|
|
@ -18,13 +18,11 @@ func TestLargeJunkPadding(t *testing.T) {
|
|||
// Write a normal tar file into the pipe and then load it full of junk
|
||||
// bytes as padding. We have to do this in a goroutine because we can't
|
||||
// store 20GB of junk in-memory.
|
||||
var err error
|
||||
go func(e error) {
|
||||
go func() {
|
||||
// Empty archive.
|
||||
tw := tar.NewWriter(pW)
|
||||
if err := tw.Close(); err != nil {
|
||||
pW.CloseWithError(err)
|
||||
e = err
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -36,7 +34,6 @@ func TestLargeJunkPadding(t *testing.T) {
|
|||
devZero, err := os.Open("/dev/zero")
|
||||
if err != nil {
|
||||
pW.CloseWithError(err)
|
||||
e = err
|
||||
return
|
||||
}
|
||||
defer devZero.Close()
|
||||
|
@ -46,17 +43,13 @@ func TestLargeJunkPadding(t *testing.T) {
|
|||
}
|
||||
if _, err := io.CopyN(pW, devZero, junkChunkSize); err != nil {
|
||||
pW.CloseWithError(err)
|
||||
e = err
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintln(os.Stderr, "[TestLargeJunkPadding] junk chunk finished")
|
||||
pW.Close()
|
||||
}(err)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
// Disassemble our junk file.
|
||||
nilPacker := storage.NewJSONPacker(ioutil.Discard)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue