I think this should be the responsability of the Caller, not the function. Like ioutil.ReadAll()