![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Go
几分钟意丶
。。。
展开
-
GoLang中go Test
go Test 单元测试 Table-driven表格驱动测试 当在测试中需要进行多case的覆盖测试,如果每次都以修改单元测试函数中的方式实现,这样无疑显得很笨拙。在此情况下,我们可以采用 Table-driven 的方式编写简洁测试。 func Fib(n int) int{ if n < 5 { return n * 3 } if n > 100 { return n } return n * 2 } func Te原创 2020-08-28 16:58:57 · 568 阅读 · 0 评论 -
Go: 数组与切片
数组是值传递,切片是指针传递 一、声明数组: var n [5]type //n是一个长度为5的数组 初始化数组: n= [5]float32{1000.0,2.0,50.0,7.0,3.4} 或者 n :=[5]float32{1000.0,2.0,50.0,7.0,3.4} 初始化数组中{}中的元素个数不能大于[]中的数字 或者 n :=[…]float32{1000.0,2.0,50....原创 2019-05-06 10:02:48 · 193 阅读 · 0 评论