github.com/aquasecurity/trivy-iac@v0.8.1-0.20240127024015-3d8e412cf0ab/pkg/scanners/azure/functions/max.go (about)

     1  package functions
     2  
     3  func Max(args ...interface{}) interface{} {
     4  	switch args[0].(type) {
     5  	case int:
     6  		var ints []int
     7  		for _, arg := range args {
     8  			ints = append(ints, arg.(int))
     9  		}
    10  		return maxInt(ints)
    11  	case interface{}:
    12  		switch iType := args[0].(type) {
    13  		case []int:
    14  			return maxInt(iType)
    15  		}
    16  	}
    17  	return 0
    18  }
    19  
    20  func maxInt(args []int) int {
    21  	if len(args) == 0 {
    22  		return 0
    23  	}
    24  
    25  	max := args[0]
    26  
    27  	for i := 1; i < len(args); i++ {
    28  		if args[i] > max {
    29  			max = args[i]
    30  		}
    31  	}
    32  	return max
    33  }