Re: [go-nuts] how to stream json to http post req

2020-09-02 Thread Alexander Mills
thanks that looks correct to me On Wednesday, September 2, 2020 at 2:16:30 PM UTC-7 bbse...@gmail.com wrote: > On Wed, Sep 2, 2020 at 2:49 PM Alexander Mills > wrote: > > > > I have the following code: > > > > ``` > > b := bytes.NewBuffer([]byte("")) > > > > go func() { > > for _, v := range z {

Re: [go-nuts] how to stream json to http post req

2020-09-02 Thread burak serdar
On Wed, Sep 2, 2020 at 2:49 PM Alexander Mills wrote: > > I have the following code: > > ``` > b := bytes.NewBuffer([]byte("")) > > go func() { > for _, v := range z { > > jsonStr, err := json.Marshal(&v) > > if err != nil { > continue > } > > b.Write([]byte(string(jsonStr) + "\n")) > } > }() > >

[go-nuts] how to stream json to http post req

2020-09-02 Thread Alexander Mills
I have the following code: ``` b := bytes.NewBuffer([]byte("")) go func() { for _, v := range z { jsonStr, err := json.Marshal(&v) if err != nil { continue } b.Write([]byte(string(jsonStr) + "\n")) } }() fullUrl := fmt.Sprintf("%s/%s", baseUrl, "_bulk") req, err := http.NewRequest("POST", fu