package zntg type Action func() func (a Action) Err() ActionErr { return func() error { a() return nil } } type ActionErr func() error type Actions []ActionErr func (a Actions) Add(fn Action) Actions { return a.AddErr(fn.Err()) } func (a Actions) AddErr(fn ActionErr) Actions { return append(a, fn) } func (a Actions) Do() { for _, a := range a { a() } } func (a Actions) DoErr() error { for _, a := range a { if err := a(); err != nil { return err } } return nil }