This is a created article in which the information may have evolved or changed.
The following summary is a recent Golang development encountered, and the internet collected on the pit, will continue to update:
The string is not \x0
judged by the end
No lock queue is only in single core, multicore also need lock, need to dispatch between threads
The formatted time string can only be used 2006 01 02 15 04 05
(the time origin) and is time/format.go
written dead:
2006-01-02T15:04:05Z07:00
In fact, this is meaningful, and each field corresponds exactly to:
1 2 3 4 5 6 7月 日 时 分 秒 年 时区
When multiple channel is in the ready state, the activation channel is random and cannot be judged in order
os.exit(1)
After execution, defer is not useful.
Goroutine The goroutine switch occurs only if the non-blocking IO call is blocked, if it is a system call:
Golang will be directly 启动内核级线程
, to realize the asynchronous ... So avoid a lot of booting system calls ...
Memory leaks in a pit If your code appears like this, congratulations, you're already in the pit.
func somefunc() { for { // ... defer something.Cleanup() }}
The reason is that the defer here have no chance of being executed. The simple solution is to put the logic here in one way.