没有合适的资源?快使用搜索试试~ 我知道了~
Anthony-Dong#note#Go如何优化的解决方法重载1
需积分: 0 0 下载量 127 浏览量
2022-07-25
14:18:44
上传
评论
收藏 2KB MD 举报
温馨提示
![preview](https://csdnimg.cn/release/download/static_files/pc/images/thumbnail/UNKNOWN.png)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
Go如何优雅的解决方法的重载1、问题你曾经是否曾经见过这样的代码func Handler(timeOut time.Duration, retry int) {
资源推荐
资源详情
资源评论
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![whl](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![whl](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
# Go如何优雅的解决方法的重载
## 1、问题
你曾经是否曾经见过这样的代码
```go
func Handler() {
//...
}
func Handler(timeOut time.Duration) {
//..
}
func Handler(timeOut time.Duration, retry int) {
//..
}
```
我就是想要处理,超时和重试哇,但是有些可以是默认值哇。怎么办,写三个方法吗,然后方法名字不同,三个方法名字,这种做法正确吗?显然是不合理的。如何解决呢。这就是go的缺点,缺点就是方法的重载。
## 2、解决问题
其实解决的思想很简单,我们知�
点击阅读更多
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/c02fd44f1e5a4ab48957971afce044aa_weixin_35795792.jpg!1)
艾苛尔
- 粉丝: 27
- 资源: 307
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)