我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

go语言中怎么利用zlib压缩数据的方法

go语言中怎么利用zlib压缩数据的方法,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

创新互联专注为客户提供全方位的互联网综合服务,包含不限于网站设计、成都网站制作、合阳网络推广、重庆小程序开发、合阳网络营销、合阳企业策划、合阳品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联为所有大学生创业者提供合阳建站搭建服务,24小时服务热线:13518219792,官方网址:www.cdcxhl.com

 代码如下:

package main
import (
    "fmt"
    "compress/zlib"
    "bytes"
)
func main() {
    var input = []byte("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKsAAAAgCAYAAABtn4gCAAAI9klEQVR4Xu2cfYxcVRmHn3Pu3Nm6lXa2ta0AYlsgFSGgThMU0W5hGkqApNGARk3cGm3BRN3FYGuCISrBXaNphcSkG2I3hn9gY2gSNWq32AoE1C6KRihFti2QSgvsTmm783HvOa+zM69cSS8Tacsq7n2SX87cj5P7ZvLs2ztnbseICG8HMjIsbxMyMnIoxhja8fJnriuYMNdjOsIVNhd0Y0wBRbxH6nHZ16OdUot2iXNDC3/2mzJtOImOnpHJ2p4Xr13ZkDTYJLHrwRgw4L1gAptIFzt87AoSuzXi/BqJ3KZ/XL1iSGLXd9aOh8u81WRksh6cefmUeFuBgmBABHEeEziwBrUVvCCxayWaSow419MY17zw4eVrz3ls9zbeKjIyWV+4bPkmiVyvCtnqps6Bta2uahJZxQs4jziHxP7fxS1I7B947tJLN5/7xBN9tIeN37yNN0EXME6LecAEGfR/746ZJeuBSy9RUVsiGucxsYPAYuxUzOtlFQEniG8JS+xRaTW+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MKZGRyao89JUd2z66+crN4unNOQsdYEIwOTCBwVgQk4gqHq4+40XO66wiLkC8xamoLgqIaiH1SiPVYPOSTz+zjdNCRiar8kjvg30f+eGVhLH0hpEl6DDY0GBy0hQWCxiQWChInU/NfZG4lsd700iAjwNcPaBez1Gv5IhqdvP5n9vbx2klI5NVefTrD/Zd9v2Vu+JItoY1U8jlbSKsdlgXCT1dBwmjkFrN4p3BxQFxs6NOxZadM2uXfT77f1cZp/kDVhrL7+wuGMOmIGd6cqEhaMSqrBfnKtw6/yAWdHnKEEe2ETP1esgLfRd9cU95Wn6RJSOTVeFD31lRMJYea80KY2n+fNAd817i3FyMCIinLMJO780u8QxdcvNTp//ngzIyWU8jGRnZrwhmZPwT5I+Pd2qC5IkAAAAASUVORK5CYII")
    var buf bytes.Buffer
    compressor, err := zlib.NewWriterLevelDict(&buf, zlib.BestCompression, input)
    if err != nil {
        fmt.Println("压缩失败")
        return
    }
    compressor.Write(input)
    compressor.Close()
    fmt.Println(buf.Bytes())
    fmt.Println(len(buf.Bytes()))
    fmt.Println(len(input))
}

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注创新互联行业资讯频道,感谢您对创新互联的支持。


网页名称:go语言中怎么利用zlib压缩数据的方法
标题URL:http://shouzuofang.com/article/ipshge.html

其他资讯