【发布时间】:2020-07-07 19:13:18
【问题描述】:
我正在尝试解码我通过另一个 fasthttp 端点发送并收到错误的 gob 输出 Fasthttp 端点(通过 gob 编码 [] 字符串)----> Fasthttp 端点(接收和解码)
buffer := &bytes.Buffer{}
buffer = ctx.PostBody()
backToStringSlice := []string{}
gob.NewDecoder(buffer).Decode(&backToStringSlice)
我收到错误:ctx.PostBody() (type []byte) as type *bytes.Buffer in assignment
如何将[]byte 转换为*bytes.Buffer。
感谢任何帮助。
【问题讨论】:
-
res := []byte{}; bytes.NewBuffer(res)