Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Leizhenpeng/golang-trick
书里没有的golang小技巧
https://github.com/Leizhenpeng/golang-trick
Last synced: 3 months ago
JSON representation
书里没有的golang小技巧
- Host: GitHub
- URL: https://github.com/Leizhenpeng/golang-trick
- Owner: Leizhenpeng
- Created: 2023-02-08T09:04:39.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-28T09:01:00.000Z (over 1 year ago)
- Last Synced: 2024-05-28T07:00:12.522Z (6 months ago)
- Language: Go
- Homepage:
- Size: 2.08 MB
- Stars: 61
- Watchers: 5
- Forks: 17
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Golang Trick
## ❤️ Help other fellow developers
Sharing is free but caring is priceless. [So, now please click here](https://www.bilibili.com/video/BV19e4y1A7DD/) and share this repository on Bilibili.
## Let's Gogogogogo!
* **[如何让idea快速实现接口](https://www.bilibili.com/video/BV19e4y1A7DD)**
_虽然go没有`imple`关键字,但依旧不影响gopher发挥._
* **[可变参数`...`操作神奇切片](https://www.bilibili.com/video/BV1CA41167dM)**_神奇...的用法._
* **[interface的nil陷阱](https://www.bilibili.com/video/BV1uT41197i4)**_golang的`interface{}`可没有ts的`any`省心._
* **[给函数返回值起好名字](https://www.bilibili.com/video/BV1dT411D7vy)**_好的习惯会给无聊代码带来一阵清风._
* **[你关注过range后面的表达式吗](https://www.bilibili.com/video/BV15Y411i7oz/)**
_不同于for,range后接的表达式只会被求值一次._
* **[永远不要在循环中更新map](https://www.bilibili.com/video/BV15Y411i7oz)**
_map是动态数据类型,你根本不知道自己的数据存储在个桶._
* **[如何更新map中的struct](https://www.bilibili.com/video/BV1ER4y1B7WY/)**
_map如果存储struct作为value,不能修改它的字段._
* **[如何优雅地实现继承](https://www.bilibili.com/video/BV1Ge4y1w7eL)**
_结构体嵌套有用,但是并非处处有用._
* **[方法接收器悖论](https://www.bilibili.com/video/BV1Ys4y1a7xy/)**
_深刻摸索两种方法集和接口的关系._
* **[闭包为何具有记忆效应](https://www.bilibili.com/video/BV14D4y1w7xP/)**
_利用内存逃逸分析解释闭包的变量记忆._
* **[责任链带你逃离IF地狱](https://www.bilibili.com/video/BV13A411U7Z4/)**
_如果业务层条件判断过多,请选择责任链吧._
* **[探索map循环随机的根本原因](https://www.bilibili.com/video/BV1JT411D7gB/)**
_从golan源代码简单看看为何map是没有顺序的._
* **[优雅的多用例单元测试](https://www.bilibili.com/video/BV1Wj411A7CN/)**
_如果针对同一函数测试用例过多,试试表驱动测试._
* **[利用Fuzz Test消灭BUG](https://www.bilibili.com/video/BV1KT411U7tF/)**
_单元测试不放心,试试模糊测试._
* **[利用卫语句消除IF嵌套](https://www.bilibili.com/video/BV18e4y1c7GW/)**
_如果某些分支为异常层,就利用Guard Clause让他们提前返回吧._
* **[如何漂亮地实现依赖注入](https://www.bilibili.com/video/BV1Db411X7dU/)**
_复杂项目不要手动注入依赖,选择WIRE解放生产力._
---
## License
Whole materials are licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.