How to convert (type *bytes.Buffer) to use as []byte in argument to w.Write

前端 未结 2 1605
借酒劲吻你
借酒劲吻你 2021-01-31 07:56

I\'m trying to return some json back from the server but get this error with the following code

cannot use buffer (type *bytes.Buffer) as type []byte in argument         


        
2条回答
  •  眼角桃花
    2021-01-31 08:31

    This is how I solved my problem

    readBuf, _ := ioutil.ReadAll(jsonStoredInBuffVariable)
    

    This code will read from the buffer variable and output []byte value

提交回复
热议问题