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 / 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]
@yakuter
yakuter / copy.go
Created February 14, 2024 11:05
Copy and Movement 1
src := []int{1, 2, 3, 4, 5}
dst := make([]int, 5)
// copy from slice to slice
copied := copy(dst, src)
// copied: 5
// dst: [1 2 3 4 5]
// copy from string to slice
var b = make([]byte, 5)
@yakuter
yakuter / Logger.swift
Created March 13, 2023 10:08
A useful logger struct in swift
// Usage
let logger = Logger("YakuterPackage.ViewController")
logger.info("Result: %{public}@", result)
logger.error("This is an error log")
// Logger.swift file content
@yakuter
yakuter / error-handling.swift
Last active March 13, 2023 10:03
Swift error handling
// Method 1
struct User {
}
enum SecurityError: Error {
case emptyEmail
case emptyPassword
}
@yakuter
yakuter / empty-struct-2.go
Last active November 3, 2022 19:40
Empty Struct 2
// Versiyon 2
package main
import "fmt"
type Foo struct{}
func main() {
a := &Foo{}
b := &Foo{}
@yakuter
yakuter / empty-struct-1.go
Last active November 3, 2022 19:40
Empty Struct
// Versiyon 1
package main
import "fmt"
type Foo struct{}
func main() {
a := &Foo{}
b := &Foo{}
@yakuter
yakuter / multipart-pipe.go
Last active September 27, 2022 08:42
Multipart and Pipe file stream
// This example shows how to send files via pipe using multipart package
package main
import (
"errors"
"fmt"
"io"
"mime/multipart"
"os"