Jitmisra commented on code in PR #1050:
URL:
https://github.com/apache/incubator-seata-go/pull/1050#discussion_r2869417915
##########
pkg/compressor/7z_compress.go:
##########
@@ -16,3 +16,50 @@
*/
package compressor
+
+import (
+ "bytes"
+ "io/ioutil"
+
+ "github.com/ulikunitz/xz/lzma"
+)
+
+type Sevenz struct{}
+
+// Compress Sevenz compress using LZMA algorithm
+func (s *Sevenz) Compress(data []byte) ([]byte, error) {
+ var buffer bytes.Buffer
+ writer, err := lzma.NewWriter(&buffer)
+ if err != nil {
+ return nil, err
+ }
+
+ if _, err := writer.Write(data); err != nil {
+ return nil, err
+ }
+
+ if err := writer.Close(); err != nil {
+ return nil, err
+ }
+
+ return buffer.Bytes(), nil
+}
+
+// Decompress Sevenz decompress using LZMA algorithm
+func (s *Sevenz) Decompress(data []byte) ([]byte, error) {
+ reader, err := lzma.NewReader(bytes.NewReader(data))
+ if err != nil {
+ return nil, err
+ }
+
+ decompressed, err := ioutil.ReadAll(reader)
Review Comment:
> `ioutil` is deprecated. Wouldn't it be better to use `io.ReadAll(reader)`
instead?
sure thanks
##########
pkg/compressor/7z_compress.go:
##########
@@ -16,3 +16,50 @@
*/
package compressor
+
+import (
+ "bytes"
+ "io/ioutil"
+
+ "github.com/ulikunitz/xz/lzma"
+)
+
+type Sevenz struct{}
+
+// Compress Sevenz compress using LZMA algorithm
+func (s *Sevenz) Compress(data []byte) ([]byte, error) {
+ var buffer bytes.Buffer
+ writer, err := lzma.NewWriter(&buffer)
+ if err != nil {
+ return nil, err
+ }
+
+ if _, err := writer.Write(data); err != nil {
+ return nil, err
+ }
+
+ if err := writer.Close(); err != nil {
Review Comment:
sure thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]