github.imxd.top/openshift/source-to-image@v1.2.0/pkg/util/strings.go (about)

     1  package util
     2  
     3  // Includes determines if the given string is in the provided slice of strings.
     4  func Includes(arr []string, str string) bool {
     5  	for _, s := range arr {
     6  		if s == str {
     7  			return true
     8  		}
     9  	}
    10  	return false
    11  }
    12  
    13  // FirstNonEmpty returns the first non-empty string in the provided list of strings.
    14  func FirstNonEmpty(args ...string) string {
    15  	for _, value := range args {
    16  		if len(value) > 0 {
    17  			return value
    18  		}
    19  	}
    20  	return ""
    21  }