企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### 基本的数据类型 * bool 布尔型 true or flalse * string 字符串 "hello world" * int、int8、int16、int32、int64 整形 * float32、float64 浮点型 * complex64、complex128 复数类型(忽略) ### 变量声明: ~~~ var (//这种写法我们一般用于常量的声明 a int b bool c string d float32 ) const f int = 100 const Pi float32 = 3.1415 fmt.Printf("a=%d b=%t c=%s d=%f f=%d\n", a, b, c, d, f) a = 10 b = true c = "hello" d = 10.8 fmt.Printf("a=%d b=%t c=%s d=%f\n", a, b, c, d) ~~~ ![](https://img.kancloud.cn/46/62/4662814ad4bf27650d68961a10f20ec2_988x118.png) ## Tips ~~~go s := "string" //只能用户函数中 左边的变量必须是一个的新的变量 ~~~ ~~~go var vname1, vname2, vname3 = 1, 2, 3 // 一次生命多个变量,自动推断 ~~~ ~~~ const ( //一次生命多个常量 常量在生命时必须赋值 a int=1 b bool=false c string="aaaa" d float32=2.23 ) ~~~