In this case you are getting the status of ‘go run’. You need to compile and run the binary to get the correct status. On Sep 23, 2024, at 9:38 AM, Maisa Unbelievable wrote:> Are you seeing the “unknown option” being output? Yes, but I didn't see that the program stopped right after it. I am not
Hi,
your for loop condition skips odd numbered argument counts. Consider:
- args = ["--bad"]
- len(args) = 1
- for i+1 < len(args) --> condition is false (1 not less than 1)
Thus the only way to trigger the os.Exit(1) is to have at least 2
arguments, of which the first is not "--name
What makes you think that the line which calls os.Exit(1) is being reached?
What are your test arguments to the program?
On Monday 23 September 2024 at 14:42:31 UTC+1 Maisa Unbelievable wrote:
> Hello there! I don't quiet understand why *os.Exit* doesn't terminate my
> program according to its d
Are you seeing the “unknown option” being output? On Sep 23, 2024, at 8:43 AM, Maisa Unbelievable wrote:Hello there! I don't quiet understand why os.Exit doesn't terminate myprogram according to its documentation:Exit causes the current program to exit with the given status code.My program implem
Hello there! I don't quiet understand why *os.Exit* doesn't terminate my
program according to its documentation:
Exit causes the current program to *exit with the given status code*.
My program implements a rudimentary CLI parsing:
package main
import (
"fmt"
"os"
)
func main() {
var name stri