21 lines
271 B
Go
21 lines
271 B
Go
|
package utils
|
||
|
|
||
|
type MustChain struct {
|
||
|
err error
|
||
|
}
|
||
|
|
||
|
func NewMust() *MustChain {
|
||
|
return &MustChain{}
|
||
|
}
|
||
|
|
||
|
func (c *MustChain) Do(callback func() error) *MustChain {
|
||
|
if c.err == nil {
|
||
|
c.err = callback()
|
||
|
}
|
||
|
return c
|
||
|
}
|
||
|
|
||
|
func (c *MustChain) Done() error {
|
||
|
return c.err
|
||
|
}
|