Re: [go-nuts] os.Exit doesn't exit the program with the specified error code as expected

2024-09-23 Thread Diego Joss
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

Re: [go-nuts] os.Exit doesn't exit the program with the specified error code as expected

2024-09-23 Thread Robert Engels
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

[go-nuts] os.Exit doesn't exit the program with the specified error code as expected

2024-09-23 Thread Maisa Unbelievable
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