1package testutil 2 3type cleanuper struct{ fns []func() } 4 5func (c *cleanuper) Cleanup(fn func()) { c.fns = append(c.fns, fn) } 6 7func (c *cleanuper) runCleanups() { 8 for i := len(c.fns) - 1; i >= 0; i-- { 9 c.fns[i]() 10 } 11} 12