Emma has been working on a small program (main.go) that takes only one argument — a lowercase word — and checks if it's a palindrome word or not:
package main
import (
"fmt"
"log"
"os"
)
func main() {
if len(os.Args) != 2 {
log.Fatal("Error! Expected 1 argument only")
}
word := os.Args[1]
for i := 0; i < len(word) / 2; i++ {
if word[i] != word[len(word) - i - 1] {
fmt.Printf("%s is not a palindrome! ❌", word)
return
}
}
fmt.Printf("%s is a palindrome! ✅", word)
}
Please enter the correct way to execute Emma's program from the command line below, using the word kayak as an argument. Remember that the name of the program is main!