摘要: Go语言使用go关键词实现goroutine并发,可以通过channel传输数据。 go关键词修饰函数实现goroutine并发: func main_go() { // runtime.GOMAXPROCS(最大256) fmt.Println(runtime.NumCPU()) // 16 ru 阅读全文
posted @ 2021-07-25 13:44 HiIT青年 阅读(46) 评论(0) 推荐(0) 编辑
摘要: Go语言时间相关的包为time。 // 时间API now := time.Now() fmt.Printf("年=%d\n", now.Year()) fmt.Printf("月=%d\n", now.Month()) fmt.Printf("日=%d\n", now.Day()) fmt.Pri 阅读全文
posted @ 2021-07-25 11:35 HiIT青年 阅读(56) 评论(0) 推荐(0) 编辑
摘要: Go语言文件操作涉及包有os和io这两个。 使用字节操作读文件: func readByteFromFile() { file, err := os.Open("go.mod") if err != nil { fmt.Printf("err >> %v\n", err) } defer file. 阅读全文
posted @ 2021-07-25 10:43 HiIT青年 阅读(35) 评论(0) 推荐(0) 编辑