Learn

fmt is one of Go’s core packages. We’ve used it for print information to the terminal using the method fmt.Println(). fmt has a broader purpose, helping us format data, which is why it’s sometimes referred to as the format package (though it’s pronounced “fumpt”, and no that’s not a typo).

But let’s not focus on the odd pronunciation, instead, let’s go over what else we can use fmt to do! In addition to Println(), there’s also Print() and Printf() each with their own variation of how to print data. There’s also Sprint(), Sprintln(), and Sprintf() which formats but does not print anything to the terminal. We can even get user input by using Scan(). There are many more methods in Go’s fmt package, but in this lesson, we’ll focus on the ones we just mentioned.

In this lesson, we’ll cover the intricacies of using these methods, so let’s go formatting!

Instructions

Examine and run the code provided. We’ll discuss in more detail what each line does in the upcoming exercises.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?