golang binary包


binary包是 golang的二进制包,

a := "hello,this is a first sentence."
//b := "hello,this is a second sentence."

//实例化一个 io容器
by := bytes.NewBuffer([]byte{})
//往里面写入4个字节的数据
binary.Write(by,binary.BigEndian,int32(len(a)))

var dataLen int32
//读取4个字节
binary.Read(by,binary.BigEndian,&dataLen)
fmt.Println(dataLen)


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM