The fmt package provides formatted I/O with functions like Printf for printing and Scanf for parsing in Go.
The fmt package provides formatted I/O with functions analogous to C's printf and scanf, handling string formatting and parsing. Use fmt.Printf to print formatted output to standard output.
package main
import "fmt"
func main() {
fmt.Printf("Hello, %s! You are %d years old.\n", "Alice", 30)
}
The fmt package is the standard tool for printing text and reading input in Go. It lets you insert variables into sentences easily, like filling in blanks on a form. You use it whenever you need to show data to a user or log information to a file.