1 Star 0 Fork 0

BowenLau/go-bindata

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
bytewriter.go 668 Bytes
一键复制 编辑 原始数据 按行查看 历史
Jim Teeuwen 提交于 2014-01-29 01:38 . Runs go fmt.
// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// license. Its contents can be found at:
// http://creativecommons.org/publicdomain/zero/1.0/
package bindata
import (
"fmt"
"io"
)
var (
newline = []byte{'\n'}
dataindent = []byte{'\t', '\t'}
space = []byte{' '}
)
type ByteWriter struct {
io.Writer
c int
}
func (w *ByteWriter) Write(p []byte) (n int, err error) {
if len(p) == 0 {
return
}
for n = range p {
if w.c%12 == 0 {
w.Writer.Write(newline)
w.Writer.Write(dataindent)
w.c = 0
} else {
w.Writer.Write(space)
}
fmt.Fprintf(w.Writer, "0x%02x,", p[n])
w.c++
}
n++
return
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lliubowen_94/go-bindata.git
git@gitee.com:lliubowen_94/go-bindata.git
lliubowen_94
go-bindata
go-bindata
master

搜索帮助