![](https://img-blog.csdnimg.cn/20210104092130826.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
go学习笔记
go学习记录
big_big_snail
这个作者很懒,什么都没留下…
展开
-
Go 学习笔记--字符串
Go 学习笔记字符串与其他主要编程语言言的差异string 是数据类型,不不是引用用或指针类型 string 是只读的 byte slice,len 函数可以它所包含的 byte 数string 的 byte 数组可以存放任何数据Unicode UTF8Unicode 是一一种字符集(code point)UTF8 是 unicode 的存储实现 (转换为字节序列列的规则)package string_testimport "testing"func TestString(原创 2021-01-05 15:41:25 · 182 阅读 · 0 评论 -
Go学习笔记--Map基础
Go 学习笔记–Map基础Map 声明m := map[string]int{"one": 1, "two": 2, "three": 3}m1 := map[string]int{}m1["one"] = 1m2 := make(map[string]int, 10 /*Initial Capacity*/)func TestInitMap(t *testing.T){ m1 := map[int]int{1:1, 2:2, 3:4} t.Log(m1[2])原创 2021-01-05 11:27:33 · 187 阅读 · 0 评论 -
Go 学习笔记--常用的集合
Go 学习笔记之常用的集合数组和切片数组的声明:var a [3]int // 声明并初始化为默认值a[0] = 1b := [3]int{1,2,3} //声明同时初始化c := [2][3]int{{1,2}, {3,4}} //多维数组赋值func TestArrayInit(t *testing.T){ var arr [3]int arr1 := [4]int{1,2,3,4} arr3 := [...]int{1,3,4原创 2021-01-05 10:04:02 · 222 阅读 · 0 评论 -
go学习笔记--条件和循环
Go学习笔记条件和循环for循环与其他主要编程语言的差异,go仅支持循环关键字forwhile 条件循环while < 5n := 0for n < 5 { n++ fmt.Println(n)}while 无限循环while(true)n := 0for { ...}test codepackage loop_testimport "testing"func TestWhileLoop(t *testing.T){ n :=原创 2021-01-04 14:52:29 · 125 阅读 · 0 评论 -
Go 学习笔记-如何编写和运行测试程序
Go 学习笔记编写和运行测试程序源码文件以 _test 结尾:xxx_test.go测试方法名以 Test 开头 func TestXXX(t *testing.T){…}package loop_testimport "testing"func TestWhileLoop(t *testing.T){ n := 0 for n < 5{ t.Log(n) //在test中,我们常使用Log() 来打印输出原创 2021-01-04 14:04:27 · 367 阅读 · 0 评论 -
go学习笔记--第一个go程序
Go学习笔记第一个go 程序hello_world.gopackage mainimport "fmt"func main() { fmt Println("Hello World")}#直接运行go run hello_world.go#先编译再运行go build hello_world.go #build 之后会生成一个二进制hello_world./hello_world基本程序结构package main // 表明代码所在的模块(包)i原创 2021-01-04 10:44:46 · 97 阅读 · 0 评论