github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/pkg/scanners/azure/functions/first.go (about)

     1  package functions
     2  
     3  func First(args ...interface{}) interface{} {
     4  	if len(args) != 1 {
     5  		return ""
     6  	}
     7  
     8  	container := args[0]
     9  
    10  	switch cType := container.(type) {
    11  	case string:
    12  		if len(cType) > 0 {
    13  			return string(cType[0])
    14  		}
    15  	case interface{}:
    16  		switch iType := cType.(type) {
    17  		case []string:
    18  			if len(iType) > 0 {
    19  				return iType[0]
    20  			}
    21  		case []bool:
    22  			if len(iType) > 0 {
    23  				return iType[0]
    24  			}
    25  		case []int:
    26  			if len(iType) > 0 {
    27  				return iType[0]
    28  			}
    29  		case []float64:
    30  			if len(iType) > 0 {
    31  				return iType[0]
    32  			}
    33  		}
    34  	}
    35  
    36  	return ""
    37  }