反引号Back quote,表示字符串字面量,与双引号不同,它不支持任何转义序列,但支持换行书写。字面量 raw literal string 的意思是,你定义时写的啥样,它就啥样,你有换行,它就换行。你写转义字符,它也就展示转义字符。
a := 'a' b := "b\naa" c := `c 3ww` var d byte = 'd' fmt.Println(b) fmt.Println(c) fmt.Printf("Single quote type:%T\n", a) fmt.Printf("Double quote type:%T\n", b) fmt.Printf("Back quote type:%T\n", c) fmt.Printf("Single quote type:%T\n", d)
output: ------ b aa c 3ww Single quote type:int32 Double quote type:string Back quote type:string Single quote type:uint8