The fmt Package
A free lesson from Swipe Coding · Go, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
fmt.Println is the most common way to print output in Go. It prints its arguments separated by single spaces and automatically adds a newline at the end, so the next thing you print starts on a fresh line without any extra work.
fmt.Println("Hello, World!")
fmt.Println("This line starts fresh.")fmt.Print is a closely related function, but it does not add that trailing newline — whatever you print next continues right where the previous call left off, on the same line. Because of this, developers reach for fmt.Println far more often, unless they specifically want output to keep building on one line.
What is the key difference between fmt.Print and fmt.Println?
fmt.Printf gives you far more control by using a format string full of format verbs — placeholders that get replaced with values you pass afterward. %s stands in for a string, %d for an integer, %f for a floating-point number, %v for a value in its default format, and %T for a value's type. Unlike Println, Printf never adds a newline for you, so you have to include \n yourself wherever you want one.
name := "Maya"
age := 21
fmt.Printf("%s is %d years old\n", name, age)The format verb ____ prints a value's type, which is especially useful for debugging.
%v is a general-purpose "default format" verb: it works with almost any value — strings, numbers, booleans, and more — and prints a reasonable default representation of it, which makes it a convenient choice while you are still learning the more specific verbs.
fmt.Printf automatically adds a newline character at the end of its output, exactly like fmt.Println does.
Keep your streak going in Swipe Coding
Swipe through every level of Go on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →