导航
×
   ❮   
HTML CSS JavaScript PHP Go ECMS

Go 字符串数据类型


字符串数据类型

string 数据类型用于存储一系列字符(文本)。字符串值必须用双引号括起来

实例

package main
import ("fmt")

func main() {
  var txt1 string = "Hello!"
  var txt2 string
  txt3 := "World 1"

  fmt.Printf("Type: %T, value: %v\n", txt1, txt1)
  fmt.Printf("Type: %T, value: %v\n", txt2, txt2)
  fmt.Printf("Type: %T, value: %v\n", txt3, txt3)
}

结果

Type: string, value: Hello!
Type: string, value
Type: string, value: World 1
亲自试一试 »

freew3c.com 中文网是独立运营的中文开发者学习平台,与 freew3c.com 无关联。提供的内容仅用于学习和测试,不保证内容的正确性。


Copyright @2020-2026 京ICP备888888号-8