Go's "multiple return values" feature, can be used for several purposes. Among them for failure reporting to the function caller. Go has two conventions for failure reporting, but currently, no clear convention for which to use when. I've encountered different programmers that prefer different choices in different cases. In this article, we will discuss the two, and try to make the process of choosing our next function signature more conscious.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package logging | |
| import ( | |
| "github.com/rs/zerolog" | |
| "github.com/rs/zerolog/log" | |
| "gopkg.in/natefinch/lumberjack.v2" | |
| "os" | |
| "path" | |
| "io" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "flag" | |
| "io" | |
| "net" | |
| "time" | |
| log "github.com/sirupsen/logrus" | |
| "golang.org/x/net/proxy" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math/big" | |
| "context" | |
| "io/ioutil" | |
| "github.com/ethereum/go-ethereum/accounts" | |
| "github.com/ethereum/go-ethereum/accounts/keystore" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript: void ((function () { | |
| /** | |
| * 功能:斗鱼自动弹幕语音朗读 | |
| * 用法:需要[制作成 Chrome 书签](http://pan.baidu.com/s/1skgEosX) | |
| * 版本:v2.0.0 | |
| * 日期:2017年12月30日 17:28:17 | |
| * 更新:2018年12月31日 16:32:25 | |
| */ | |
| const speaker = (word, rate = 1) => { | |
| if (word !== '') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * USB HID Keyboard scan codes as per USB spec 1.11 | |
| * plus some additional codes | |
| * | |
| * Created by MightyPork, 2016 | |
| * Public domain | |
| * | |
| * Adapted from: | |
| * https://source.android.com/devices/input/keyboard-devices.html | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #满足了一下自己的搜集癖,搜集了不少可以用来查询外网IP的网址和方法。 | |
| #国内某网站的接口,只返回IP | |
| curl ip.6655.com/ip.aspx | |
| curl whatismyip.akamai.com | |
| curl ipip.net | |
| #更多用法访问ifconfig.co | |
| wget -qO - ifconfig.co | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| 电信 | |
| 中国电信手机号码开头数字 | |
| 2G/3G号段(CDMA2000网络)133、153、180、181、189 | |
| 4G号段 177 | |
| 联通 | |
| 中国联通手机号码开头数字 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Add copy to clipboard from IPython! | |
| To install, just copy it to your profile/startup directory, typically: | |
| ~/.ipython/profile_default/startup/ | |
| Example usage: | |
| %copy hello world | |
| # will store "hello world" |