Изменения в новых версиях / Go 1.18

// *** before: ***
func SumInts(nums []intint {
    total := 0
    for _, n := range nums {
        total += n
    }
    return total
}

func SumFloats(nums []float64) float64 {
    total := 0.0
    for _, n := range nums {
        total += n
    }
    return total
}

// *** in version 1.18: ***
func Sum[T int | float64](nums []T) T {
    var total T
    for _, n := range nums {
        total += n
    }
    return total
}