← All Exercises
Go String Formatting
basicgo
Background
The fmt package provides C-style format verbs for type-safe string construction in Go.
Problem
Write a Go function that formats a product struct into a display string with aligned columns and price formatting.
Input
A product name (string), price (float64), and quantity (int).
Output
A formatted display string with aligned columns.
Sample tests
Sample 1
Input: "Widget", 9.99, 3
Expected: "Widget $ 9.99 x 3 = $ 29.97"
Your solution
Learning objective
Learn fmt.Sprintf format verbs, width/precision specifiers, and alignment flags.