ZhangZhihui's Blog  

Code and project organization:

#1: Unintended variable shadowing

#2: Unnecessary nested code

#3: Misusing init functions

#4: Overusing getters and setters

#5: Interface pollution

#6: Interface on the producer side

#7: Returning interfaces

#8: any says nothing

#9: Being confused about when to use generics

#10: Not being aware of the possible problems with type embedding

#11: Not using the functional options pattern

#12: Project misorganization

#13: Creating utility packages

#14: Ignoring package name collisions

#15: Missing code documentation

#16: Not using linters

Data types:

#17: Creating confusion with octal literals

#18: Neglecting integer overflows

#19: Not understanding floating points

#20: Not understanding slice length and capacity

#21: Inefficient slice initialization

#22: Being confused about nil vs. empty slices

#23: Not properly checking if a slice is empty

#24: Not making slice copies correctly

#25: Unexpected side effects using slice append

#26: Slices and memory leaks

#27: Inefficient map initialization

#28: Maps and memory leaks

#29: Comparing values incorrectly

Control structures:

#30: Ignoring the fact that elements are copied in range loops

#31: Ignoring how arguments are evaluated in range loops

#32: Ignoring the impact of using pointer elements in range loops (There's no longer this issue from Go 1.22.)

#33: Making wrong assumptions during map iterations

#34: Ignoring how the break statement works

#35: Using defer inside a loop

Strings:

#36: Not understanding the concept of a rune

#37: Inaccurate string iteration

#38: Misusing trim functions

#39: Under-optimized string concatenation

#40: Useless string conversions

#41: Substrings and memory leaks

Functions and methods:

#42: Not knowing which type of receiver to use

#43: Never using named result parameters

#44: Unintended side effects with named result parameters

#45: Returning a nil receiver

#46: Using a filename as a function input

#47: Ignoring how defer arguments and receivers are evaluated

Error management:

#48: Panicking

#49: Ignoring when to wrap an error

#50: Checking an error type inaccurately

#51: Checking an error value inaccurately

#52: Handling an error twice

#53: Not handling an error

#54: Not handling defer errors

Concurrency: Foundations

#55: Mixing up concurrency and parallelism

#56: Thinking concurrency is always faster

#57: Being puzzled about when to use channels or mutexes

#58: Not understanding race problems

#59: Not understanding the concurrency impacts of a workload type

#60: Misunderstanding Go contexts

Concurrency: Practice

#61: Propagating an inappropriate context

#62: Starting a goroutine without knowing when to stop it

#63: Not being careful with goroutines and loop variables (This problem doesn't exist from Go version 1.22)

#64: Expecting deterministic behavior using select and channels

#65: Not using notification channels

#66: Not using nil channels

#67: Being puzzled about channel size

#68: Forgetting about possible side effects with string formatting

#69: Creating data races with append

#70: Using mutexes inaccurately with slices and maps

#71: Misusing sync.WaitGroup

#72: Forgetting about sync.Cond

#73: Not using errgroup

#74: Copying a sync type

The standard library:

#75: Providing a wrong time duration

#76: time.After and memory leaks

#77: Common JSON-handling mistakes

#78: Common SQL mistakes

#79: Not closing transient resources

#80: Forgetting the return statement after replying to an HTTP request

#81: Using the default HTTP client and server

Testing:

#82: Not categorizing tests

#83: Not enabling the -race flag

#84: Not using test execution modes

#85: Not using table-driven tests

#86: Sleeping in unit tests

#87: Not dealing with the time API efficiently

#88: Not using testing utility packages

#89: Writing inaccurate benchmarks

#90: Not exploring all the Go testing features

Optimizations:

#91: Not understanding CPU caches

#92: Writing concurrent code that leads to false sharing

#93: Not taking into account instruction-level parallelism

#94: Not being aware of data alignment

#95: Not understanding stack vs. heap

#96: Not knowing how to reduce allocations

#97: Not relying on inlining

#98: Not using Go diagnostics tooling

#99: Not understanding how the GC works

#100: Not understanding the impacts of running Go in Docker and Kubernetes

posted on   ZhangZhihuiAAA  阅读(8)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
 
点击右上角即可分享
微信分享提示