Course outline
Course / The terminal and the language

Route the support ticket

Lab

How to fetch and submit this lab

Once: install the tool and connect your account.

curl -fsSL https://gonomicon.com/install.sh | sh
gonomicon login

Each 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 submit

Go installed? gonomicon test runs the visible test on your computer first. Submitting also runs hidden checks on our server.

Goal 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. Route has a // TODO comment and a return line you will change.
  • If Outage is true, return "page-oncall" immediately, no matter what Plan or Severity are.
  • Otherwise, normalize Plan with strings.TrimSpace and then strings.ToLower before comparing it to anything — the caller may send " Enterprise ".
  • If the normalized plan is "enterprise" and Severity is 4 or 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 a switch on the normalized plan for the rest. Do not change the var declarations or the Route function 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

  1. 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.
  2. 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.
  3. 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" }

Something wrong with this lesson? Report a problem