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)