Pure GO implementation of flip