I’m stuck on Stage #IP1.
I am trying to check if the “custom_exe_” exists in the command by doing a
strings.Contains(cmd, "custom_exe_")
but it returns a boolean value, which I can’t use because of the switch statement and cause cmd is a string
so how do I match it
Here are my logs:
[tester::#IP1] Running ./your_program.sh
[your-program] $ custom_exe_2902 Alice
[your-program] custom_exe_2902: command not found
[tester::#IP1] Output does not match expected value.
[tester::#IP1] Expected: "Program was passed 2 args (including program name)."
[tester::#IP1] Received: "custom_exe_2902: command not found"
[your-program] $
[tester::#IP1] Assertion failed.
[tester::#IP1] Test failed
And here’s a snippet of my code:
for {
fmt.Fprint(os.Stdout, "$ ")
input, err := bufio.NewReader(os.Stdin).ReadString('\n')
if err != nil {
fmt.Fprintln(os.Stderr, "Error reading input: ", err)
os.Exit(1)
}
cmdArr := strings.Fields(input)
cmd := cmdArr[0]
if strings.TrimSpace(input) == "exit 0" {
break
}
customExeExists := strings.Contains(cmd, "custom_exe_")
switch cmd {
case "echo":
EchoCmd(cmdArr)
case "type":
TypeCmd(cmdArr)
case customExeExists:
CustomExeCmd(cmdArr)
default:
fmt.Println(strings.TrimSpace(cmd) + ": command not found")
}
}