摘要:
写代码过程中,有时需要分析代码块的时间消耗。 本文介绍使用time包中的Since函数查看程序执行时间。 package main import ( "fmt" "time" ) func main() { t := time.Now() fmt.Println("Hello") for i:=0; 阅读全文
posted @ 2022-10-17 10:31
opensmarty
阅读(281)
评论(0)
推荐(0)
摘要:
1. os包 1.1 Write()/WriteString()方法 语法 打开文件 func OpenFile(name string, flag int, perm FileMode) (*File, error) 写入 func (f *File) WriteString(s string) 阅读全文
posted @ 2022-10-17 10:23
opensmarty
阅读(1168)
评论(0)
推荐(0)
摘要:
网络通信中,为了防止长时间无响应的情况,经常会用到网络连接超时、读写超时的设置。 本文结合例子简介golang的连接超时和读写超时设置。 1.超时设置 1.1 连接超时 func DialTimeout(network, address string, timeout time.Duration) 阅读全文
posted @ 2022-10-17 10:09
opensmarty
阅读(1352)
评论(0)
推荐(0)

浙公网安备 33010602011771号