上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 61 下一页
摘要: init函数有一下几点特性: init函数在main执行之前,自动被调用执行的,不能显示调用 每个包的init函数在包被引用时,自动被调用 每个包可以有多个init函数 同一个文件中可定义多个init()函数 package main import ( "fmt" ) func init() { f 阅读全文
posted @ 2022-10-17 10:43 opensmarty 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 写代码过程中,有时需要分析代码块的时间消耗。 本文介绍使用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 阅读(224) 评论(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 阅读(842) 评论(0) 推荐(0) 编辑
摘要: 网络通信中,为了防止长时间无响应的情况,经常会用到网络连接超时、读写超时的设置。 本文结合例子简介golang的连接超时和读写超时设置。 1.超时设置 1.1 连接超时 func DialTimeout(network, address string, timeout time.Duration) 阅读全文
posted @ 2022-10-17 10:09 opensmarty 阅读(905) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2022-10-08 09:27 opensmarty 阅读(0) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2022-09-20 15:31 opensmarty 阅读(0) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2022-09-20 10:35 opensmarty 阅读(0) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2022-09-20 10:21 opensmarty 阅读(0) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2022-09-16 14:24 opensmarty 阅读(0) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2022-09-16 11:11 opensmarty 阅读(0) 评论(0) 推荐(0) 编辑
上一页 1 ··· 25 26 27 28 29 30 31 32 33 ··· 61 下一页