编辑代码

package main

import (
	"fmt"
)

func main() {
	const name, age = "Kim", 22
    fmt.Print('\n', " m\n") // 不能使用 format 参数字符串,两个相邻的参数不为字符串之间添加空格
	fmt.Print(name, " is ", age, " years old.\n")
    fmt.Print("%s is %d years old.", name, age, "\n")
    fmt.Printf("%sis%dyearsold.\n", name, age) // 第一个参数为 format 参数字符串
    fmt.Println("--------------------") // 不能使用 format 参数字符串, 相邻参数之间添加空格输出并在输出结束后换行
    str := fmt.Sprint(name, "is", age, "years old.")
    fmt.Println(str)
    val := fmt.Sprintf("%s is %d years old.", name, age)
    fmt.Print(val, "\n")
    fmt.Println("-------------------")
    fmt.Println(name, "is", age, "years old.")
    fmt.Println("%sis%dyearsold.",name,age)
    fmt.Println("hello","world","everybody",age)
}