Open asu126 opened 6 years ago
buf, _ := ioutil.ReadAll(r.Body)
rdr1 := ioutil.NopCloser(bytes.NewBuffer(buf))
rdr2 := ioutil.NopCloser(bytes.NewBuffer(buf))
doStuff(rdr1) r.Body = rdr2 // OK since rdr2 implements the io.ReadCloser interface
// Now the program can continue oblivious to the fact that // r.Body was ever touched.
import "strings"
startsWith := strings.HasPrefix("prefix", "pre") // true endsWith := strings.HasSuffix("suffix", "fix") // true