在golang中将字节追加到字节缓冲区

我有一个消息字节缓冲区,我想在缓冲区末尾附加一个字节 我试图像这样追加:
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作为要附加的切片呢?

You have a buffer which is of type bytes.Buffer (or more specifically a pointer to that type). It has a Buffer.WriteByte() method, just use that:

message.Buf.WriteByte(0xff)

The builtin append() function which you tried to call is to append values to slices. bytes.Buffer is not a slice, you can't use that with append() (it is implemented using an internal slice, but that is an implementation detail which you should not build on / utilize).