Below you will see a Go program named multiply_numbers.go that multiplies two int numbers given as arguments:
package main
import (
"fmt"
"log"
"os"
"strconv"
)
func main() {
if len(os.Args) < 3 {
log.Fatal("Please provide two integer numbers as arguments")
}
num1, err := strconv.Atoi(os.Args[1])
if err != nil {
log.Fatal(err)
}
num2, err := strconv.Atoi(os.Args[2])
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d * %d = %d", num1, num2, num1*num2)
}
Select all the correct ways to run the program multiply_numbers to multiply two numbers below.
Tip: It is also possible to run a Go program that takes arguments and hasn't been compiled using the go run ... syntax