Here's how you can use the fmt
package in Go to print an integer value:
main.go104 chars9 lines
Here, we've declared a variable num
with a value of 42
. We then use fmt.Printf
to print the value of num
with the %d
format specifier. The %d
format specifier is used for printing integers.
When you run this program, it should output:
main.go23 chars2 lines
gistlibby LogSnag