func f() error { var a, b, c *handle var err error if a, err = acquireHandle(0); err != nil { return err } defer a.Close() if a, err = acquireHandle(1); err != nil { return err } defer b.Close() if a, err = acquireHandle(2); err != nil { return err } defer c.Close() //use a, b, c return nil }