摘要: 声明Slice var empty []int // an empty slice withData := []int{0,1,2,3,4,5} // a slice pre-filled with some data make([]T, len) make([]T, len, cap) // sa 阅读全文
posted @ 2023-02-18 21:48 roadwide 阅读(45) 评论(0) 推荐(0) 编辑
摘要: General %v the value in a default format when printing structs, the plus flag (%+v) adds field names %#v a Go-syntax representation of the value %T a 阅读全文
posted @ 2023-02-18 21:24 roadwide 阅读(15) 评论(0) 推荐(0) 编辑
摘要: Strings A string in Go is an immutable(不可变的) sequence of bytes, which don't necessarily have to represent characters. double quotes("") 和 backticks(`) 阅读全文
posted @ 2023-02-18 15:19 roadwide 阅读(48) 评论(0) 推荐(0) 编辑
摘要: Numbers int64取值范围是多少?(面试题) [-2^63, 2^63-1] int64就是用64bit表示一个数字,由于需要区分正负,所以减去1位的符号位,符号位0表示正,1表示负。剩下63位来表示数字。 或者这样想,不考虑符号,64bit最大的数是2^64-1,也就是64位全1。再把这个 阅读全文
posted @ 2023-02-18 13:59 roadwide 阅读(178) 评论(0) 推荐(0) 编辑
摘要: Packages Go语言中的包和其他语言的库或模块的概念类似,目的都是为了支持模块化、封装、单独编译和代码重用。一个包的源代码保存在一个或多个以.go为文件后缀名的源文件中,通常一个包所在目录路径的后缀是包的导入路径;例如包gopl.io/ch1/helloworld对应的目录路径是 $GOPAT 阅读全文
posted @ 2023-02-18 13:01 roadwide 阅读(20) 评论(0) 推荐(0) 编辑