Example to compare Println vs Printf
Println formats using the default formats for its operands and writes to standard output. Printf formats according to a format specifier and writes to standard output.
Example
package main
import "fmt"
func main() {
a, b, c := 10, 20, 30
fmt.Println(
"(a + b = c) :", a, "+", b, "=", c,
)
fmt.Printf(
"(a + b = c) : %d + %d = %d\n", a, b, c,
)
}
Output
(a + b = c) : 10 + 20 = 30
(a + b = c) : 10 + 20 = 30
Most Helpful This Week
Golang write CSV records
How do you create an HTTP server in Go?
How to change slice item value in Golang?
How to copy one slice items into another slice in Golang?
How to create Slice using Make function in Golang?
Web Application to read and write JSON data in JSON File
Make Your Retirement Luxurious with These 5 Game-Changing Altcoins
How do you handle HTTP responses in Go?
GO language program with example of Sort Functions for integer, strings and float64 data type
Example of Interface with Type Embedding and Method Overriding in GO language