you can achieve this using an io.Pipe. The io.Pipe function returns a
connected pair of *PipeReader and *PipeWriter, where writes to the
*PipeWriter are directly read from the *PipeReader. The Write call on the
*PipeWriter will block until the data is read from the *PipeReader.

pr, pw := io.Pipe()

Pass the pr as the body and write to the pw.

On Wed, Mar 22, 2023, 7:06 PM 'Jim Smart' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> The issue here, isn’t that I am uploading a big file — that’s easy.
>
> As I said in my initial post:
>
> > The use case here is that I'm wishing to send very large UPDATE/INSERT
> queries/commands to an HTTP endpoint, and the body content of those
> queries/commands is actually generated from a database.
>
> The content I wish to push to the server, is /generated/ content. So
> really what I want is a something I can directly write into.
>
> I am trying to avoid generating my upload content into a buffer first.
> Because the data can be very large.
>
> — It’s easy to say “write a reader” but writing it as a reader involves
> doing complete inversion of control on my code, and isn’t really feasible.
> I can’t easily make the code I have which has complex logic to build the
> upload data using Writes, into something that is then driven by Reads.
>
> Which is why I asked if it was possible to somehow Write straight down the
> connection.
>
>
> — Thanks for the suggestions all the same.
>
> /J
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/C5B2823D-2458-4F91-A09D-6B12F74CD8B3%40jimsmart.org
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CA%2Bh8R2pTUXsWPpywxhRJi_Bs3ZP0hmVP%3DkqZMe6FwJWJS-3BDg%40mail.gmail.com.

Reply via email to