Body io.ReadCloser
It seems that the only way is to replace Bodywith an object that matches io.ReadCloser. To do this, you need to build the object Bodyusing any function that returns the object io.Readerand ioutil.NopCloserto enable the io.Readerobject io.ReadCloser.
bytes.NewBufferString
NewBufferString , s . .
strings.NewReader ( )
NewReader s. bytes.NewBufferString, .
ioutil.NopCloser
NopCloser ReadCloser no-op Close, Reader r.
new_body_content := "New content."
r.Body = ioutil.NopCloser(strings.NewReader(new_body_content))
, Request, Body. ContentLength:
r.ContentLength = int64(len(new_body_content))
, Body, TransferEncoding.
source
share