【发布时间】:2017-09-29 23:45:43
【问题描述】:
我有一个消息字节缓冲区,我想在缓冲区末尾附加一个字节
我试着像这样追加:
append(message.Buf, 0xff)
first argument to append must be slice; have *bytes.Buffer
append(0xff,message.Buf)
first argument to append must be slice; have untyped number
如何将 0xff 作为切片进行附加?
【问题讨论】:
-
函数
append用于将值附加到切片,并且 absolutely nothing 与不是切片的 bytes.Buffer 相关。只需写入您的 bytes.Buffer。请阅读文档,尤其是golang.org/pkg/bytes/#Buffer.WriteByte