Skip to content

Instantly share code, notes, and snippets.

View dumindu's full-sized avatar
🌱
One step at a time...

Dumindu Madunuwan dumindu

🌱
One step at a time...
View GitHub Profile
package main
import "fmt"
func main() {
ch := make(chan int)
go write(ch)
for v := range ch {
package main
import "fmt"
func main() {
ch := make(chan string, 1)
ch <- "Hello world!"
fmt.Println(<-ch)
package main
import (
"fmt"
"sync"
)
func main() {
wg := sync.WaitGroup{}
wg.Add(1)
package main
import (
"fmt"
"sync"
)
func main() {
wg := sync.WaitGroup{} // 1. Create a WaitGroup
wg.Add(1) // 2. Add 1 to WaitGroup counter
package main
import (
"fmt"
"sync"
)
var wg = sync.WaitGroup{} // 1. Create a WaitGroup
func main() {
package main
import (
"fmt"
"time"
)
func main() {
go sayHello()
package main
import "fmt"
func main() {
go sayHello()
}
func sayHello() {
fmt.Println("Hello world!")
package main
import "fmt"
func main() {
sayHello()
}
func sayHello() {
fmt.Println("Hello world!")
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: helloworld.proto
package helloworld
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: helloworld.proto
package helloworld
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)