Precursor: I'm just starting to get my feet wet with golang.
This may prove to a be a silly question as it's quite easy to perform these calculations but I'm going to ask it anyway as I didn't find an answer when Googling.
Is there a built in function that returns the minimum of a slice of int arguments:
func MinIntSlice(v []int) (m int) {
if len(v) > 0 {
m = v[0]
}
for i := 1; i < len(v); i++ {
if v[i] < m {
m = v[i]
}
}
return
}
OR the minimum of a variable number of int arguments:
func MinIntVarible(v1 int, vn ...int) (m int) {
m = v1
for i := 0; i < len(vn); i++ {
if vn[i] < m {
m = vn[i]
}
}
return
}
If not, is the best "convention" simply to create a package that contains helpers like this?