Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Bug in helpers.ReaderToString(reader io.ReadCloser) string #34

@deze333

Description

@deze333

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 %v appended 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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions