Skip to content

zing-dev/hello-go

Repository files navigation

learn-go

This is an open source project to learn golang

package main import ( "context""log""sync""time" ) funcHelloWorld(){time.Sleep(time.Second) log.Println("Hello, World!") } funcHelloWorld2(){c:=make(chanstruct{}) gofunc(){time.Sleep(time.Second) log.Println("Hello, World chan!") c<-struct{}{} }() <-c } funcHelloWorld3(){varg sync.WaitGroupg.Add(1) gofunc(){time.Sleep(time.Second) log.Println("Hello, World WaitGroup!") g.Done() }() g.Wait() } funcHelloWorld4(){cond:=sync.NewCond(new(sync.Mutex)) gofunc(){time.Sleep(time.Second) log.Println("Hello, World Cond!") cond.Signal() }() cond.L.Lock() cond.Wait() cond.L.Unlock() } funcHelloWorld5(){ctx, cancel:=context.WithCancel(context.Background()) gocancel() select{case<-ctx.Done(): time.Sleep(time.Second) log.Println("Hello, World WithCancel!") } } funcmain(){HelloWorld() HelloWorld2() HelloWorld3() HelloWorld4() HelloWorld5() }

Releases

No releases published

Packages

No packages published