我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

如何模拟写入gzip文件?

I can write a normal gzip file:

var b bytes.Buffer
w := gzip.NewWriter(&b)
w.Write([]byte("hello, world
"))
w.Close()

But I cannot figure out how to mock a gzip file so that I can read that mocked file for my tests:

afero.WriteFile(mfs, "/path/to/file.gz", []byte("here is file"), 0644)

If I try to read this mock gzip file the error I get is:

gzip: invalid header

近期文章

  • 将数据从客户端发送到服务器-REST Web服务
  • http.StripPrefix:从自定义文件夹提供文件
  • 根据golang中的结构值搜索记录
  • 在Windows上的Atom上构建Chaincode(hyperledger)失败
  • 测试Go中未导出函数的命名约定
  • 用一个结构初始化单链表
  • 为nats-streaming设置处理程序时进行比赛数据检测
  • 如何在未定义main()的情况下让cgo生成目标文件?
  • Maven不会使用mvn-golang-wrapper插件上传maven-metadata.xml
  • 如何在Gorm中正确执行部分更新?
  • 从串口获取输入
  • 从Angular JS到GoLang的HTML格式化数据发送和处理
  • 将变量从中间件传递到最终功能
  • Websockets与大猩猩/ websocket一起用于用户通知
  • DDD从值对象列表中删除文本值对象
  • 为什么goroutines不使用WriteAt并行编写?
  • 升级后转到sqlite3代码停止工作
  • Golang http.Get在容器中显示错误EOF
  • 从头开始在Docker映像下执行时间不起作用
  • 根据测试中的通用包定义结构

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华