摘要:
Because the mutex is embedded, we can directly access the Lock and Unlock methods from the i receiver.We mentioned that such an example is a wrong usa
阅读全文
posted @ 2024-02-13 21:41
ZhangZhihuiAAA
阅读(9)
推荐(0)
摘要:
Go 1.18 adds generics to the language. In a nutshell, this allows writing code with types that can be specified later and instantiated when needed. On
阅读全文
posted @ 2024-02-13 19:05
ZhangZhihuiAAA
阅读(15)
推荐(0)
摘要:
With Go 1.18, the predeclared type any became an alias for an empty interface; hence, all the interface{} occurrences can be replaced by any. If futur
阅读全文
posted @ 2024-02-13 17:12
ZhangZhihuiAAA
阅读(18)
推荐(0)
摘要:
All in all, in most cases, we shouldn’t return interfaces but concrete implementations. Otherwise, it can make our design more complex due to package
阅读全文
posted @ 2024-02-13 16:12
ZhangZhihuiAAA
阅读(5)
推荐(0)
摘要:
The SOLID principles are a set of design guidelines that help developers write more maintainable, scalable, and testable code. First introduced by Rob
阅读全文
posted @ 2024-02-13 15:40
ZhangZhihuiAAA
阅读(17)
推荐(0)
摘要:
An interface should live on the consumer side in most cases. However, in particular contexts (for example, when we know—not foresee—that an abstractio
阅读全文
posted @ 2024-02-13 15:28
ZhangZhihuiAAA
阅读(7)
推荐(0)
摘要:
Code and project organization: #1: Unintended variable shadowing #2: Unnecessary nested code #3: Misusing init functions #4: Overusing getters and set
阅读全文
posted @ 2024-02-13 15:25
ZhangZhihuiAAA
阅读(20)
推荐(0)
摘要:
Common behavior Decoupling Restricting behavior Common behavior: Restricting behavior:The last use case we will discuss can be pretty counterintuitive
阅读全文
posted @ 2024-02-13 14:34
ZhangZhihuiAAA
阅读(11)
推荐(0)