GOLANG
Free Section Starter Challenge
25 min
3. Multiple Return Values & Idiomatic Error Handling
Overview: Return results and errors explicitly: `func fn() (int, error)`.
Concept & Syntax Guide
Go does not use exceptions. Instead, functions return `(result, error)`. Idiomatic Go checks `if err != nil` immediately.
Hands-On Practice Exercise
Implement an Order Validator Function
Write a function `func validateOrder(price int) (string, bool)` that returns ("Valid", true) if price > 0.
Target Output:
Status: Order Approved (OK: true)
Need a hint? Click here to reveal
Hint: Check syntax carefully and make sure your code contains:
Status: Order Approved (OK: true)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10