directory
0.0.0-20241220033105-d0a631aabad2
Repository: https://github.com/dwhdxp/go_learn.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
No description provided by the author
使用接口实现一个简易日志库,要求可以向文件中写,也可以向终端写
*/.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
1.goroutine是轻量级用户线程,由go进行调度,并且go会动态的为其分配合适的栈空间(几KB);
2.当需要让任务并发执行时,只需要将任务包装成一个函数,开启goroutine执行函数;
3.当main goroutine over时,所有main创建的sub goroutine都会over;
*/.
1.channel可能在多个任务函数中被使用,通常我们会选择在不同的任务函数中对通道的使用进行限制,
比如限制通道在某个函数中只能执行发送或只能执行接收操作,这时就需要单向channel;
2.双向channel可以转换为单向channel,但是反过来不可以
*/.
No description provided by the author
No description provided by the author
1.recover()必须搭配defer使用,panic会直接终止程序,终止后会执行defer
2.defer必须在出现panic的位置之前定义,否则会导致无法被注册,panic出现后程序会直接崩溃,程序不会注册defer
*/.
No description provided by the author
No description provided by the author
No description provided by the author