Skip to content

Instantly share code, notes, and snippets.

@yakuter
Created February 15, 2024 07:54
Show Gist options
  • Save yakuter/29e0aa2981a783f821cf6f05c4fec4a6 to your computer and use it in GitHub Desktop.
Save yakuter/29e0aa2981a783f821cf6f05c4fec4a6 to your computer and use it in GitHub Desktop.
Copy and Movement 3
package main
import (
"fmt"
"io"
"os"
)
func main() {
reader, writer := io.Pipe()
// PipeWriter'a yazma işlemini bir gorutinde gerçekleştir
go func() {
_, err := writer.Write([]byte("Merhaba, io.Pipe kullanımı!"))
if err != nil {
fmt.Println("Yazma hatası:", err)
return
}
writer.Close()
}()
// PipeReader'dan okuma işlemini ana gorutinde gerçekleştir
if _, err := io.Copy(os.Stdout, reader); err != nil {
fmt.Println("Okuma hatası:", err)
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment