You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
472 B
32 lines
472 B
3 years ago
|
package routine_test
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"time"
|
||
|
|
||
|
"gitoa.ru/go-4devs/closer/routine"
|
||
|
)
|
||
|
|
||
|
func ExampleGo() {
|
||
|
defer routine.Close()
|
||
|
routine.Go(func() {
|
||
|
time.Sleep(time.Microsecond)
|
||
|
fmt.Print("do some job")
|
||
|
})
|
||
|
|
||
|
// Output: do some job
|
||
|
}
|
||
|
|
||
|
func ExampleRun() {
|
||
|
defer routine.Close()
|
||
|
|
||
|
routine.Run(func() {
|
||
|
time.Sleep(time.Microsecond)
|
||
|
fmt.Print("do some job. ")
|
||
|
}, func() {
|
||
|
fmt.Print("fast job in goroutine. ")
|
||
|
})
|
||
|
|
||
|
// Output: fast job in goroutine. do some job.
|
||
|
}
|