xerogolang
xerogolang copied to clipboard
Bug in helpers.ReaderToString(reader io.ReadCloser) string
A small bug in helpers.go that results in:
- the function must return a string, not print it, as a (unwanted) result errors get printed twice to console
- (unneeded) call to
fmt.Printf(newString)missing format string resulting in%vappended to output
As a workaround I simply commented out unneeded lines:
//ReaderToString converts an io.ReadCloser to a string
func ReaderToString(reader io.ReadCloser) string {
if reader == nil {
return ""
}
buf := new(bytes.Buffer)
_, err := buf.ReadFrom(reader)
if err != nil {
return ""
}
newString := buf.String()
// BUG: Not needed
// _, err = fmt.Printf(newString) // incomplete arguments list
// if err != nil {
// return ""
// }
return newString
}