github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/comparison/strings.go (about)

     1  package comparison
     2  
     3  // StringSlicesEqual determines whether or not two string slices are equal. It
     4  // does not consider nilness when comparing zero-length slices.
     5  func StringSlicesEqual(first, second []string) bool {
     6  	// Check that slice lengths are equal.
     7  	if len(first) != len(second) {
     8  		return false
     9  	}
    10  
    11  	// Compare contents.
    12  	for i, f := range first {
    13  		if second[i] != f {
    14  			return false
    15  		}
    16  	}
    17  
    18  	// The slices are equal.
    19  	return true
    20  }
    21  
    22  // StringMapsEqual determines whether or not two string maps are equal. It does
    23  // not consider nilness when comparing zero-length maps.
    24  func StringMapsEqual(first, second map[string]string) bool {
    25  	// Check that map lengths are equal.
    26  	if len(first) != len(second) {
    27  		return false
    28  	}
    29  
    30  	// Compare contents.
    31  	for key, f := range first {
    32  		if s, ok := second[key]; !ok || s != f {
    33  			return false
    34  		}
    35  	}
    36  
    37  	// The maps are equal.
    38  	return true
    39  }