24 lines
312 B
Go
24 lines
312 B
Go
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.Atoi(os.Args[i])
|
|
result = result + float64(sum)
|
|
}
|
|
|
|
fmt.Printf("%v\n", result)
|
|
}
|