Println, Sprintf and Errorf
Println adds spaces and newline, Sprintf returns a string and Errorf builds errors.
Example
package main
import "fmt"
func main() {
s := fmt.Sprintf("%d-%d", 1, 2)
err := fmt.Errorf("bad %s", "input")
fmt.Println(s, err)
}Result
1-2 bad input
Exercise
Return a formatted string.
s := fmt.("%d", 1)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.