Skip to content

How to make an if statement trigger if args is blank #2270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rhhen122 opened this issue Apr 20, 2025 · 1 comment
Open

How to make an if statement trigger if args is blank #2270

rhhen122 opened this issue Apr 20, 2025 · 1 comment

Comments

@rhhen122
Copy link

Hi, I wanted to make an if statement trigger if args is blank.
Just wondering how i could do that!
Thanks

@Mrityunjay20
Copy link

the arguments if blank would still contain its zero values, you could equate the args with their specific zero values and trigger the if statement

e.g.
func processArgs(name string, age int, hobbies []string, config map[string]string) {
fmt.Println("\n--- Processing Arguments ---")
fmt.Printf("Received: name="%s", age=%d, hobbies=%v, config=%v\n", name, age, hobbies, config)

// Check if the 'name' argument is blank (empty string)
if name == "" {
	fmt.Println("Condition triggered: 'name' argument is blank (empty string).")
	// You can add specific logic here for a blank name
}

Here is a document for your reference

https://www.scaler.com/topics/golang/golang-zero-values/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants