func main() { runtime.GOMAXPROCS(runtime.NumCPU()) for i := 0; i < 10; i++ { // normal usage sample. go func() { l := ulog.New() l.Action("task 1") wait(100) l.Action("task 2") wait(200) l.Done() }() // struct sample. go func() { m := &O{} m.Foo() m.Bar() }() // func sample. go SomethingToDo() } <-time.After(time.Second) }
// Bar func. func (x *O) Bar() error { x.l = ulog.New() wait(400) x.l.Action("BAR") wait(100) x.l.Done() return nil }
// Foo func. func (x *O) Foo() error { x.l = ulog.New() wait(100) x.l.Action("searching 1") wait(300) x.l.Done() return nil }
// SomethingToDo func. func SomethingToDo() { l := ulog.New() wait(40) l.Action("Task A") wait(140) l.Action("Task B") wait(180) l.Action("Task C") wait(600) l.Action("Task D") l.Done() return }