1 Star 0 Fork 0

timesp / go-git

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
write.go 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
package binary
import (
"encoding/binary"
"io"
)
// Write writes the binary representation of data into w, using BigEndian order
// https://golang.org/pkg/encoding/binary/#Write
func Write(w io.Writer, data ...interface{}) error {
for _, v := range data {
if err := binary.Write(w, binary.BigEndian, v); err != nil {
return err
}
}
return nil
}
func WriteVariableWidthInt(w io.Writer, n int64) error {
buf := []byte{byte(n & 0x7f)}
n >>= 7
for n != 0 {
n--
buf = append([]byte{0x80 | (byte(n & 0x7f))}, buf...)
n >>= 7
}
_, err := w.Write(buf)
return err
}
// WriteUint64 writes the binary representation of a uint64 into w, in BigEndian
// order
func WriteUint64(w io.Writer, value uint64) error {
return binary.Write(w, binary.BigEndian, value)
}
// WriteUint32 writes the binary representation of a uint32 into w, in BigEndian
// order
func WriteUint32(w io.Writer, value uint32) error {
return binary.Write(w, binary.BigEndian, value)
}
// WriteUint16 writes the binary representation of a uint16 into w, in BigEndian
// order
func WriteUint16(w io.Writer, value uint16) error {
return binary.Write(w, binary.BigEndian, value)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/timesp/go-git.git
git@gitee.com:timesp/go-git.git
timesp
go-git
go-git
v4.4.0

搜索帮助

344bd9b3 5694891 D2dac590 5694891