func removePolicy(existingPolicy *policyDoc, resourceTypes, resourceID, action string) bool {
	a, ok := existingPolicy.Policies[resourceTypes]
	if !ok { // means resource type/policy does not exist
		return ok // resourcetype/policy does not exist error can also be returned
	}

	resourceIDs, ok := a[action]
	if !ok { // means action/policy does not exist
		return ok
	}

	idx := sliceIndex(len(resourceIDs), func(i int) bool { return resourceIDs[i] == resourceID })
	if idx < 0 {
		return false
	}

	resourceIDs[idx], resourceIDs[len(resourceIDs)-1] = resourceIDs[len(resourceIDs)-1], resourceIDs[idx]
	resourceIDs = resourceIDs[:len(resourceIDs)-1]

	a[action] = resourceIDs
	return true
}
// removePolicy would remove newPolicy from existing policy
removePolicy would remove newPolicy from existing policy
// removePolicy would remove newPolicy from existing policy
func removePolicy(existingPolicy *policyDoc, resourceTypes, resourceID, action string) bool {
	a, ok := existingPolicy.Policies[resourceTypes]
	if !ok { 
		return ok 
	}
	resourceIDs, ok := a[action]
	if !ok { 
		return ok
	}
	idx := sliceIndex(len(resourceIDs), func(i int) bool { return resourceIDs[i] == resourceID })
	if idx < 0 {
		return false
	}
	resourceIDs[idx], resourceIDs[len(resourceIDs)-1] = resourceIDs[len(resourceIDs)-1], resourceIDs[idx]
	resourceIDs = resourceIDs[:len(resourceIDs)-1]
	a[action] = resourceIDs
	return true
}
func removePolicy ( existingPolicy * policyDoc , resourceTypes , resourceID , action string ) bool { a , ok := existingPolicy . Policies [ resourceTypes ] if ! ok { return ok } resourceIDs , ok := a [ action ] if ! ok { return ok } idx := sliceIndex ( len ( resourceIDs ) , func ( i int ) bool { return resourceIDs [ i ] == resourceID } ) if idx < 0 { return false } resourceIDs [ idx ] , resourceIDs [ len ( resourceIDs ) - 1 ] = resourceIDs [ len ( resourceIDs ) - 1 ] , resourceIDs [ idx ] resourceIDs = resourceIDs [ : len ( resourceIDs ) - 1 ] a [ action ] = resourceIDs return true }
removePolicy would remove newPolicy from existing policy
removePolicy would remove newPolicy from existing policy
// means resource type/policy does not exist // resourcetype/policy does not exist error can also be returned // means action/policy does not exist