Skip to content

Instantly share code, notes, and snippets.

@narenaryan
Created June 5, 2022 11:20
Show Gist options
  • Select an option

  • Save narenaryan/45431931aa15503fc768e6b785702bab to your computer and use it in GitHub Desktop.

Select an option

Save narenaryan/45431931aa15503fc768e6b785702bab to your computer and use it in GitHub Desktop.
package main
import (
"bytes"
"fmt"
"io"
"strings"
)
func main() {
// Create a reader
r := strings.NewReader("Hello Medium")
// Create a writer
var b bytes.Buffer
// Copy data
_, err := io.Copy(&b, r) // Don't forget &
if err != nil {
panic(err)
}
// Optional: verify data
fmt.Println(b.String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment