Reading from and writing to a file without passing around filename
you could use a teereader:

inr, inw := io.Pipe()
f, _ := os.Create(name)
tr := io.TeeReader(inr, f)
return tr, inw


use this code in go routine and handle errors