Skip to content

Instantly share code, notes, and snippets.

View yakuter's full-sized avatar
💭
Working #golang @binalyze

Erhan Yakut yakuter

💭
Working #golang @binalyze
View GitHub Profile
@yakuter
yakuter / ioReaderRight.go
Created February 15, 2024 21:02
Copy and Movement 11
package main
import (
"fmt"
"io"
"strings"
)
func main() {
reader := strings.NewReader("This is a test message.")
@yakuter
yakuter / ioReaderWrong.go
Created February 15, 2024 20:56
Copy and Movement 10
package main
import (
"fmt"
"io"
"strings"
)
func main() {
reader := strings.NewReader("Test")
@yakuter
yakuter / bufio.go
Created February 15, 2024 20:24
Copy and Movement 9
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
file, err := os.Open("example.txt")
@yakuter
yakuter / bytesBuffer.go
Created February 15, 2024 18:34
Copy and Movement 8
package main
import (
"bytes"
"fmt"
)
func main() {
var buffer bytes.Buffer
@yakuter
yakuter / ioPipeHttpServer.go
Created February 15, 2024 17:25
Copy and Movement 7
package main
import (
"io"
"net/http"
"os"
)
func main() {
http.HandleFunc("/download", func(w http.ResponseWriter, r *http.Request) {
@yakuter
yakuter / ioPipeHttpRequest.go
Created February 15, 2024 17:03
Copy and Movement 6
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
@yakuter
yakuter / channel.go
Created February 15, 2024 09:05
Copy and Movement 5
package main
import (
"fmt"
"time"
)
func main() {
messageChannel := make(chan string)
@yakuter
yakuter / ioCopy.go
Created February 15, 2024 08:24
Copy and Movement 4
package main
import (
"fmt"
"io"
"os"
)
func main() {
sourcePath := "source.txt"
@yakuter
yakuter / ioPipe.go
Created February 15, 2024 07:54
Copy and Movement 3
package main
import (
"fmt"
"io"
"os"
)
func main() {
reader, writer := io.Pipe()
@yakuter
yakuter / append.go
Created February 14, 2024 15:13
Copy and Movement 2
package main
import "fmt"
func main() {
var s []int
// len=0 cap=0 []
s = append(s, 0) // append works on nil slices.
// len=1 cap=1 [0]