You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: dupe_bindings.go
    path of file: ./repos/rancher/pkg/agent/clean
    
    the code of the file until where you have to start completion: //go:build !windows
// +build !windows

/*
Clean duplicates bindings found in a management cluster. This will collect all
PRTBs and CRTBs, create the labels used to identify the k8s resources that correspond
to those and check for duplicates. If they are found delete all but 1.
This is technically safe as rancher will recreate any CRB or RB that is deleted that
should not have been.
*/

package clean

import (
	"context"
	"fmt"
	"os"
	"sort"
	"strings"
	"sync"

	"github.com/hashicorp/go-multierror"
	apiv3 "github.com/rancher/ranch
    
func (bc *dupeBindingsCleanup) dedupeCRB(bindings []k8srbacv1.ClusterRoleBinding) error {
	//check if CRB with deterministic name exists
	deterministicFound, crbName, err := bc.checkIfDeterministicCRBExists(bindings[0])
	if err != nil {
		if !k8sErrors.IsNotFound(err) {
			logrus.Errorf("[%v] error attempting to lookup deterministic CRB: %v", dupeBindingsOperation, err)
		}
		logrus.Infof("[%v] binding with deterministic name not found, will delete all except the oldest binding", dupeBindingsOperation)
	}

	duplicates := bindings
	if !deterministicFound {
		// Sort by creation timestamp so we keep the oldest
		sort.Sort(crbByCreation(bindings))
		// Leave the first one alone, we only need the duplicates
		duplicates = bindings[1:]
	}

	for _, binding := range duplicates {
		if deterministicFound && strings.EqualFold(binding.Name, crbName) {
			logrus.Infof("[%v] found the CRB with the deterministic name %v, will not delete this", dupeBindingsOperation, binding.Name)
			continue
		}
		if !dryRun {
			if err := bc.clusterRoleBindings.Delete(binding.Name, &metav1.DeleteOptions{}); err != nil {
				logrus.Errorf("[%v] error attempting to delete CRB %v %v", dupeBindingsOperation, binding.Name, err)
			}
		} else {
			logrus.Infof("[%v] dryRun enabled, clusterRoleBinding %v would be deleted", dupeBindingsOperation, binding.Name)
		}
	}
	return nil
}