Golang学习笔记 (一)
2015-11-08 17:16
615 查看
小记一下go的语法,风格
关于Exported names ,首字母不是大写的都不能作为输出。也不能被导入到另一个包中然后使用。
int型在32位系统上为32位,在64位系统上为64位,和C一样。
Variables declared without an explicit initial value are given their zero value.变量未被赋值时:0 for numeric types,
false the boolean type, and
“” (the empty string) for strings.
import :在同时引入多个包时,可以放在括号中。如
Type conversions:类型转换 The expression T(v) converts the value v to the type T. 类型转换时,必须显式转换,Unlike in C, in Go assignment between items of different type requires an explicit conversion.
Type inference: the variable’s type is inferred from the value on the right hand side.
fmt.Printf() fmt.Printfln()(输出行)
Constants:
Constants are declared like variables, but with the const keyword.
-
关于Exported names ,首字母不是大写的都不能作为输出。也不能被导入到另一个包中然后使用。
int型在32位系统上为32位,在64位系统上为64位,和C一样。
Variables declared without an explicit initial value are given their zero value.变量未被赋值时:0 for numeric types,
false the boolean type, and
“” (the empty string) for strings.
import :在同时引入多个包时,可以放在括号中。如
import ( "fmt" "math" )
Type conversions:类型转换 The expression T(v) converts the value v to the type T. 类型转换时,必须显式转换,Unlike in C, in Go assignment between items of different type requires an explicit conversion.
Type inference: the variable’s type is inferred from the value on the right hand side.
fmt.Printf() fmt.Printfln()(输出行)
Constants:
Constants are declared like variables, but with the const keyword.
*Constants can be character, string, boolean, or numeric values.* *Constants cannot be declared using the := syntax.*
-
相关文章推荐
- Go 语言 Channel 实现原理精要
- Go语言将支持Android
- SQLSERVER 中GO的作用详解
- Golang实现的聊天程序服务端和客户端代码分享
- 在Go语言程序中使用gojson来解析JSON格式文件
- 举例详解Go语言中os库的常用函数用法
- Go语言中函数的参数传递与调用的基本方法
- 深入解析Go语言的io.ioutil标准库使用
- GO语言的IO方法实例小结
- Go语言的os包中常用函数初步归纳
- Go语言中数组的基本用法演示
- GO语言类型转换和类型断言实例分析
- Golang学习笔记(三):控制流
- 深入解析Go语言编程中的递归使用
- 初步解读Golang中的接口相关编写方法
- Golang学习笔记(二):类型、变量、常量
- Go语言实现的最简单数独解法
- Golang中的sync.WaitGroup用法实例
- 详解Golang编程中的常量与变量
- Go实现比较时间大小