-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
32 lines (26 loc) · 1010 Bytes
/
Copy pathexample_test.go
File metadata and controls
32 lines (26 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package compress_test
import (
"fmt"
"log"
"github.com/nativebpm/compress"
)
// Example illustrates basic usage of GzipCompress and GzipDecompress using pooled gzip readers/writers
// to minimize allocations under high concurrency.
func Example() {
originalText := []byte("NativeBPM high-performance gzip compression demo payload text.")
// 1. Compress the byte slice
compressedBytes, err := compress.GzipCompress(originalText)
if err != nil {
log.Fatalf("Compression failed: %v", err)
}
fmt.Printf("Compression output is non-empty: %t\n", len(compressedBytes) > 0)
// 2. Decompress the byte slice back to original text
decompressedBytes, err := compress.GzipDecompress(compressedBytes)
if err != nil {
log.Fatalf("Decompression failed: %v", err)
}
fmt.Println("Decompressed data matches original:", string(decompressedBytes))
// Output:
// Compression output is non-empty: true
// Decompressed data matches original: NativeBPM high-performance gzip compression demo payload text.
}