package main import ( "fmt" "os" "strconv" ) var result float64 func main() { if len(os.Args) < 2 { fmt.Println("Usage: ./sum-args 1 2 3 4 5 6") os.Exit(1) } for i := 1; i < len(os.Args); i++ { sum, _ := strconv.ParseFloat(os.Args[i], 64) result = result + float64(sum) } averageResult := getAverage(result, len(os.Args)-1) fmt.Printf("Total sum: %.4v\n", result) fmt.Printf("Average: %.4v\n", averageResult) } func getAverage(num float64, quantity int) (finalNum float64) { finalNum = num / float64(quantity) return finalNum }