Created
February 15, 2024 07:54
-
-
Save yakuter/29e0aa2981a783f821cf6f05c4fec4a6 to your computer and use it in GitHub Desktop.
Copy and Movement 3
This file contains 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 ( | |
"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