Golang中bufio的修改

I reading big file and sending this file by http POST. I use bufio.

And now I want to modify one of first line of this file, how to do it ?

f := bufio.NewReaderSize(os.Stdin, 65536)
bufPart, err := f.Peek(65536))
//how to modify bufPart(f) ?
...
req, err := http.NewRequest("POST", url, f)

Two ideas how to do it:

  1. Create your own Reader implementation that wraps an bufio.Reader and implements replacing logic (you will have to count number of read bytes).

  2. Call io.Pipe, pass the returned PipeReader to NewRequest and start a separate goroutine that will read data from a file, modify it and write to the returned PipeWriter.

Hope this makes sense.