Skip to content

Instantly share code, notes, and snippets.

@mytholog
Forked from tejainece/StreamToString.go
Created July 5, 2017 07:36
Show Gist options
  • Select an option

  • Save mytholog/1a888fa8ebf84bb7335420f06591ae59 to your computer and use it in GitHub Desktop.

Select an option

Save mytholog/1a888fa8ebf84bb7335420f06591ae59 to your computer and use it in GitHub Desktop.

Revisions

  1. @tejainece tejainece created this gist Apr 2, 2014.
    13 changes: 13 additions & 0 deletions StreamToString.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    import "bytes"

    func StreamToByte(stream io.Reader) []byte {
    buf := new(bytes.Buffer)
    buf.ReadFrom(stream)
    return buf.Bytes()
    }

    func StreamToString(stream io.Reader) string {
    buf := new(bytes.Buffer)
    buf.ReadFrom(stream)
    return buf.String()
    }