Skip to content

Commit

Permalink
Merge pull request #23 from karelbilek/gofmt
Browse files Browse the repository at this point in the history
Run gofmt
  • Loading branch information
4kills authored Dec 6, 2024
2 parents 25e4748 + 92bd384 commit e7ba546
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 32 deletions.
10 changes: 7 additions & 3 deletions decompress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import (
"testing"
)

/*---------------------
UNIT TESTS
-----------------------*/
/*
---------------------
UNIT TESTS
-----------------------
*/
func TestDecompressZlibConvenience(t *testing.T) {
// compress with go standard lib
buf := &bytes.Buffer{}
Expand Down
2 changes: 1 addition & 1 deletion native/compressing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package native
#include "libdeflate.h"
typedef struct libdeflate_compressor comp;
*/
*/
import "C"
import "unsafe"

Expand Down
4 changes: 2 additions & 2 deletions native/decompressing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef enum libdeflate_result res;
size_t* mkPtr(size_t s) {
return (size_t*) s;
}
*/
*/
import "C"
import "unsafe"

Expand Down Expand Up @@ -55,4 +55,4 @@ func parseResult(r C.res) error {
default:
return errorUnknown
}
}
}
4 changes: 2 additions & 2 deletions native/decompressor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import "unsafe"

// Decompressor decompresses any DEFLATE, zlib or gzip compressed data at any level
type Decompressor struct {
dc *C.decomp
isClosed bool
dc *C.decomp
isClosed bool
maxDecompressionFactor int
}

Expand Down
16 changes: 8 additions & 8 deletions native/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package native
import "errors"

var (
errorOutOfMemory = errors.New("libdeflate: native: out of memory")
errorInvalidLevel = errors.New("libdeflate: native: illegal compression level")
errorShortBuffer = errors.New("libdeflate: native: short buffer")
errorNoInput = errors.New("libdeflate: native: empty input")
errorBadData = errors.New("libdeflate: native: bad data: data was corrupted, invalid or unsupported")
errorUnknown = errors.New("libdeflate: native: unknown error code from c library")
errorShortOutput = errors.New("libdeflate: native: buffer too long: decompressed to fewer bytes than expected, indicating possible error in decompression. Make sure your out buffer has the exact length of the decompressed data or pass nil for out")
errorAlreadyClosed = errors.New("libdeflate: native: (de-)compressor already closed. It must not be used anymore")
errorOutOfMemory = errors.New("libdeflate: native: out of memory")
errorInvalidLevel = errors.New("libdeflate: native: illegal compression level")
errorShortBuffer = errors.New("libdeflate: native: short buffer")
errorNoInput = errors.New("libdeflate: native: empty input")
errorBadData = errors.New("libdeflate: native: bad data: data was corrupted, invalid or unsupported")
errorUnknown = errors.New("libdeflate: native: unknown error code from c library")
errorShortOutput = errors.New("libdeflate: native: buffer too long: decompressed to fewer bytes than expected, indicating possible error in decompression. Make sure your out buffer has the exact length of the decompressed data or pass nil for out")
errorAlreadyClosed = errors.New("libdeflate: native: (de-)compressor already closed. It must not be used anymore")
errorInsufficientDecompressionFactor = errors.New("libdeflate: native: your compressed data seems to be extraordinarily large when decompressed. " +
"However, this could also indicate corrupted data. The current maximum decompression factor does not allow for larger decompression, try to increase it")

Expand Down
10 changes: 7 additions & 3 deletions v2/decompress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import (
"testing"
)

/*---------------------
UNIT TESTS
-----------------------*/
/*
---------------------
UNIT TESTS
-----------------------
*/
func TestDecompressZlibConvenience(t *testing.T) {
// compress with go standard lib
buf := &bytes.Buffer{}
Expand Down
2 changes: 1 addition & 1 deletion v2/native/compressing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package native
#include "libdeflate.h"
typedef struct libdeflate_compressor comp;
*/
*/
import "C"
import "unsafe"

Expand Down
4 changes: 2 additions & 2 deletions v2/native/decompressing.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef enum libdeflate_result res;
size_t* mkPtr(size_t s) {
return (size_t*) s;
}
*/
*/
import "C"
import "unsafe"

Expand Down Expand Up @@ -58,4 +58,4 @@ func parseResult(r C.res) error {
default:
return errorUnknown
}
}
}
4 changes: 2 additions & 2 deletions v2/native/decompressor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestDecompress(t *testing.T) {
slicesEqual(shortString, out, t)

c, out, err := dc.Decompress(in, nil, DecompressZlib)
if err != nil || c != len(in){
if err != nil || c != len(in) {
t.Error(err)
}
slicesEqual(shortString, out, t)
Expand All @@ -67,7 +67,7 @@ func TestDecompressOversizedInput(t *testing.T) {
slicesEqual(shortString, out, t)

c, out, err := dc.Decompress(oversized, nil, DecompressZlib)
if err != nil || c != len(in){
if err != nil || c != len(in) {
t.Error(err)
}
slicesEqual(shortString, out, t)
Expand Down
16 changes: 8 additions & 8 deletions v2/native/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package native
import "errors"

var (
errorOutOfMemory = errors.New("libdeflate: native: out of memory")
errorInvalidLevel = errors.New("libdeflate: native: illegal compression level")
errorShortBuffer = errors.New("libdeflate: native: short buffer")
errorNoInput = errors.New("libdeflate: native: empty input")
errorBadData = errors.New("libdeflate: native: bad data: data was corrupted, invalid or unsupported")
errorUnknown = errors.New("libdeflate: native: unknown error code from c library")
errorShortOutput = errors.New("libdeflate: native: buffer too long: decompressed to fewer bytes than expected, indicating possible error in decompression. Make sure your out buffer has the exact length of the decompressed data or pass nil for out")
errorAlreadyClosed = errors.New("libdeflate: native: (de-)compressor already closed. It must not be used anymore")
errorOutOfMemory = errors.New("libdeflate: native: out of memory")
errorInvalidLevel = errors.New("libdeflate: native: illegal compression level")
errorShortBuffer = errors.New("libdeflate: native: short buffer")
errorNoInput = errors.New("libdeflate: native: empty input")
errorBadData = errors.New("libdeflate: native: bad data: data was corrupted, invalid or unsupported")
errorUnknown = errors.New("libdeflate: native: unknown error code from c library")
errorShortOutput = errors.New("libdeflate: native: buffer too long: decompressed to fewer bytes than expected, indicating possible error in decompression. Make sure your out buffer has the exact length of the decompressed data or pass nil for out")
errorAlreadyClosed = errors.New("libdeflate: native: (de-)compressor already closed. It must not be used anymore")
errorInsufficientDecompressionFactor = errors.New("libdeflate: native: your compressed data seems to be extraordinarily large when decompressed. " +
"However, this could also indicate corrupted data. The current maximum decompression factor does not allow for larger decompression, try to increase it")

Expand Down

0 comments on commit e7ba546

Please sign in to comment.