Created
June 5, 2022 11:20
-
-
Save narenaryan/45431931aa15503fc768e6b785702bab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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