fmt is one of Go’s core packages. We’ve used it for print information to the terminal using the method
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
Printf() each with their own variation of how to print data. There’s also
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!
Examine and run the code provided. We’ll discuss in more detail what each line does in the upcoming exercises.