Skip to content

Instantly share code, notes, and snippets.

View horzu's full-sized avatar

Mert Şakar horzu

View GitHub Profile
package main
import "fmt"
func main() {
jobs := make(chan int, 100)
results := make(chan int, 100)
go worker(jobs, results)
go worker(jobs, results)
@horzu
horzu / pattern: worker pool
Created March 17, 2022 22:06
pattern: worker pool
package main
import "fmt"
func main() {
jobs := make(chan int, 100)
results := make(chan int, 100)
go worker(jobs, results)
@horzu
horzu / select-2
Created March 17, 2022 21:51
select-2
package main
import (
"fmt"
"time"
)
func main() {
c1 := make(chan string)
c2 := make(chan string)
@horzu
horzu / select-1
Created March 17, 2022 21:40
select-1
package main
import (
"fmt"
"time"
)
func main() {
c1 := make(chan string)
c2 := make(chan string)
@horzu
horzu / channels-8
Created March 17, 2022 21:23
channels-8
package main
import (
"fmt"
)
func main() {
c := make(chan string, 2)
c <- "first"
c <- "second"
@horzu
horzu / channels-7
Created March 17, 2022 21:20
channels-7
package main
import (
"fmt"
)
func main() {
c := make(chan string, 2)
c <- "first"
c <- "second"
@horzu
horzu / channels-6
Created March 17, 2022 21:17
channels-6
package main
import (
"fmt"
)
func main() {
c := make(chan string, 2)
c <- "first"
@horzu
horzu / channels-5
Created March 17, 2022 21:10
channels-5
package main
import (
"fmt"
)
func main() {
c := make(chan string)
c <- "first"
@horzu
horzu / channels-4
Last active March 17, 2022 20:43
channels-4
package main
import (
"fmt"
"time"
)
func main() {
c := make(chan string)
go counter("first", c)
@horzu
horzu / channels-3
Created March 17, 2022 20:31
channels-3
package main
import (
"fmt"
"time"
)
func main() {
c := make(chan string)
go counter("first", c)