不废话,直接上代码

import (
    "bytes"
    "compress/gzip"
)

func main(){
    data := []byte(hello world)
    gzipCompress(&data)
}

func gzipCompress(content *[]byte) []byte {
    var compressData bytes.Buffer
    gzipWriter := gzip.NewWriter(&compressData)
    defer gzipWriter.Close()
    gzipWriter.Write(*content)
    gzipWriter.Flush()
    return compressData.Bytes()
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2021-06-11
  • 2021-06-09
  • 2022-12-23
相关资源
相似解决方案