摘要: package main import ( "fmt" ) func main() { var mapSlice []map[string]int fmt.Printf("before mapSlice init %v len=%d,cap%d\n",mapSlice,len(mapSlice),c 阅读全文
posted @ 2022-03-12 23:58 ty1539 阅读(435) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "time" ) func testTime() { now := time.Now() fmt.Printf("current time: %v\n ", now) year := now.Year() month := now.Month( 阅读全文
posted @ 2022-03-12 18:30 ty1539 阅读(347) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" "time" _ "time" "sync" ) /*需求:现在要计算 1-200 的各个数的阶乘,并且把各个数的阶乘放入到map中。 最后显示出来。要求使用goroutine完成 思路 1. 编写一个函数,来计算各个数的阶乘,并放入到 map 阅读全文
posted @ 2022-03-12 17:05 ty1539 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 说明 map: 字典、映射 key———value key:唯一、无序。不能是引用类型数据。 map 不能便用cap() 创建方式: 1. var m1 map[int]string 不能存储数据 2. m2 := map[int]string 能存储数据 3. m3 := make(map[int 阅读全文
posted @ 2022-03-12 13:31 ty1539 阅读(378) 评论(0) 推荐(0) 编辑