- 2024-11-28No more blunders
Thereoncewasatimeblunderingwasn'tathing,andatthattimeIalmostneverblundermypoints,andgettingconstantrank1inourgrade.Thatwasbeforecomingtocdqz.Atthattime,thiswasoneofmygreatestadvantageamongpeers.However,in
- 2024-06-22go mistakes
1.map一定要初始化,slice可以不用初始化2.pointer一定要初始化varc*Course=>mustinit=>c=&Course{}ornew(Course)3.for-loop的临时变量是一个值会变化的变量varout[]*intfori:=0;i<3;i++{//保存的是i的地址,但是i最后会变成3,slice里全部是3out=appe
- 2024-06-176.16 9
importtkinterastkfromtkinterimportttk,messageboximportdb_connectionfromupdateimportUpdatePageimporttime#查询数据库并返回结果deffetch_mistakes(search_text=""):conn1=db_connection.create_connection()cursor=conn1.cursor()
- 2024-03-03Go 100 mistakes - #97: Not relying on inlining
- 2024-03-03Go 100 mistakes - #96: Not knowing how to reduce allocations
- 2024-03-03Go 100 mistakes - #95: Not understanding stack vs. heap
- 2024-03-03Go 100 mistakes - #94: Not being aware of data alignment
- 2024-03-02Go 100 mistakes - #89: Writing inaccurate benchmarks
- 2024-02-29Go 100 mistakes - #86: Sleeping in unit tests
- 2024-02-29Go 100 mistakes - #82: Not categorizing tests
- 2024-02-29Go 100 mistakes - #81: Using the default HTTP client and server
- 2024-02-27Go 100 mistakes - #79: Not closing transient resources
- 2024-02-27Go 100 mistakes - #78: Common SQL mistakes
- 2024-02-26Go 100 mistakes - #77: Common JSON-handling mistakes
- 2024-02-26Go 100 mistakes - #76: time.After and memory leaks
- 2024-02-25Go 100 mistakes - #71: Misusing sync.WaitGroup
- 2024-02-25Go 100 mistakes - #69: Creating data races with append
- 2024-02-23Go 100 mistakes - Expecting deterministic behavior using select and channels
funcmain(){messageCh:=make(chanint,10)disconnectCh:=make(chanstruct{},1)fori:=0;i<10;i++{messageCh<-i}gofunc(){for{select{casev:=<-messageCh:
- 2024-02-23Go 100 mistakes - #61: Propagating an inappropriate context
疑问:前两种情况(1.客户端连接中断2.HTTP请求取消)发生,publish却不expire也不会被cancel,这样会不会有问题?
- 2024-02-21Go 100 mistakes - #50: Checking an error type inaccurately
- 2024-02-21Go 100 mistakes - #42: Not knowing which type of receiver to use
- 2024-02-21Go 100 mistakes - #41: Substrings and memory leaks
WeneedtokeeptwothingsinmindwhileusingthesubstringoperationinGo. First,theintervalprovidedisbasedonthenumberofbytes,notthenumberofrunes. Second,asubstringoperationmayleadtoamemoryleakastheresultings
- 2024-02-21Go 100 mistakes - #39: Under-optimized string concatenation
- 2024-02-21Go 100 mistakes - #37: Inaccurate string iteration
- 2024-02-15Go 100 mistakes - #26: Slices and memory leaks
Asaruleofthumb,rememberthatslicingalargesliceorarraycanleadtopotential highmemoryconsumption.Theremainingspacewon’tbereclaimedbytheGC,and wecankeepalargebackingarraydespiteusingonlyafewelements.Using