Course / The terminal and the language
Route the support ticket
How to fetch and submit this lab
Once: install the tool and connect your account.
curl -fsSL https://gonomicon.com/install.sh | sh
gonomicon loginEach lab: download it, edit the file named in the instructions, then submit.
gonomicon fetch week-1/10-06-route-the-ticket
cd 10-06-route-the-ticket
gonomicon submitGoal Route a support ticket to a queue by combining an early-return guard, a boolean condition, and a switch over a normalized plan name.
Example If you needed a similar shipping-tier router, you'd write:
func ShipTier() string {
if Expedited {
return "overnight"
}
tier := strings.ToLower(strings.TrimSpace(Tier))
if tier == "gold" && OrderValue >= 100 {
return "priority"
}
switch tier {
case "gold":
return "standard-gold"
default:
return "standard"
}
}
Rules
- Edit
route.go.Routehas a// TODOcomment and a return line you will change. - If
Outageistrue, return"page-oncall"immediately, no matter whatPlanorSeverityare. - Otherwise, normalize
Planwithstrings.TrimSpaceand thenstrings.ToLowerbefore comparing it to anything — the caller may send" Enterprise ". - If the normalized plan is
"enterprise"andSeverityis4or more, return"urgent". - Any other ticket on the
"enterprise"plan returns"priority". - Anything else (including an unknown or empty plan) returns
"standard". - Use an early return for the outage guard, a combined
&&condition for the urgent check, and aswitchon the normalized plan for the rest. Do not change thevardeclarations or theRoutefunction signature.
What you'll practice
Normalizing input with the strings package, combining a condition with &&, and structuring a function with a guard, a combined check, and a switch.
Run it
gonomicon fetch week-1/10-06-route-the-ticket
cd 10-06-route-the-ticket
gonomicon test
gonomicon submit
Hints
- An outage always wins, whatever the plan — check it first and return immediately. Then normalize Plan with strings.TrimSpace and strings.ToLower before comparing it to anything.
- Combine the enterprise-and-severe check with &&: plan == "enterprise" && Severity >= 4. Everything else about the plan can be a switch on the normalized plan string.
- if Outage { return "page-oncall" } plan := strings.ToLower(strings.TrimSpace(Plan)) if plan == "enterprise" && Severity >= 4 { return "urgent" } switch plan { case "enterprise": return "priority" default: return "standard" }