// Equal returns true if the given Locks represents the same information as
// the receiver.
//
// Equal explicitly _does not_ consider the equality of version constraints
// in the saved locks, because those are saved only as hints to help the UI
// explain what's changed between runs, and are never used as part of
// dependency installation decisions.
Equal returns true if the given Locks represents the same information as
the receiver.

Equal explicitly _does not_ consider the equality of version constraints
in the saved locks, because those are saved only as hints to help the UI
explain what's changed between runs, and are never used as part of
dependency installation decisions.
// Equal returns true if the given Locks represents the same information as // the receiver . // // Equal explicitly _does not_ consider the equality of version constraints // in the saved locks because those are saved only as hints to help the UI // explain what ' s changed between runs and are never used as part of // dependency installation decisions .
func (l *Locks) Equal(other *Locks) bool {
	if len(l.providers) != len(other.providers) {
		return false
	}
	for addr, thisLock := range l.providers {
		otherLock, ok := other.providers[addr]
		if !ok {
			return false
		}
		if thisLock.addr != otherLock.addr {
			return false
		}
		if thisLock.version != otherLock.version {
			return false
		}
		if len(thisLock.hashes) != len(otherLock.hashes) {
			return false
		}
		for i := range thisLock.hashes {
			if thisLock.hashes[i] != otherLock.hashes[i] {
				return false
			}
		}
	}
	return true
}
func ( l * Locks ) Equal ( other * Locks ) bool { if len ( l . providers ) != len ( other . providers ) { return false } for addr , thisLock := range l . providers { otherLock , ok := other . providers [ addr ] if ! ok { return false } if thisLock . addr != otherLock . addr { return false } if thisLock . version != otherLock . version { return false } if len ( thisLock . hashes ) != len ( otherLock . hashes ) { return false } for i := range thisLock . hashes { if thisLock . hashes [ i ] != otherLock . hashes [ i ] { return false } } } return true }
Equal returns true if the given Locks represents the same information as
the receiver.
Equal returns true if the given Locks represents the same information as the receiver .
// It'd be weird to get here because we already looked these up // by address above. // Equality rather than "Version.Same" because changes to the // build metadata are significant for the purpose of this function: // it's a different package even if it has the same precedence. // Although "hashes" is declared as a slice, it's logically an // unordered set. However, we normalize the slice of hashes when // recieving it in NewProviderLock, so we can just do a simple // item-by-item equality test here. // We don't need to worry about providers that are in "other" but not // in the receiver, because we tested the lengths being equal above.