3 ms·
I've used a pattern such as this in my code [1]: do := func(n int, err error) { if err != nil { panic(err) } } do(string.Write(/* 1 */))
by AYBABTME 13y ago
I've used a pattern such as this in my code [1]:
do := func(n int, err error) {
if err != nil {
panic(err)
}
}
do(string.Write(/* 1 */))
do(string.Write(/* 2 */))
// ...
do(string.Write(/* n */))
In fact, the pattern I've found is to declare throw-away lambdas [2] that I then call (few lines later). I haven't looked at all the pros/cons of doing this, but so far I find it's a very versatile way of doing.
[1]: https://github.com/aybabtme/graph/blob/master/digraph.go#L61 https://github.com/aybabtme/graph/blob/master/digraph.go#L61
[2]: https://github.com/aybabtme/graph/blob/master/digraph.go#L103 https://github.com/aybabtme/graph/blob/master/digraph.go#L10...