Skip to content

Instantly share code, notes, and snippets.

@elisarver
elisarver / pet-snippet.toml
Created March 13, 2017 21:41
description
[[snippets]]
description = "Sync upload"
command = "pet sync -u"
@elisarver
elisarver / wow_closures_in.go
Created February 23, 2016 01:01
From Errors are Values (https://blog.golang.org/errors-are-values) – a pretty fantastic use of closures. Each of those writes passes along the result of the write to the next command and exits *before* trying the next step. This may solve an issue I've been having in several languages.
var err error
write := func(buf []byte) {
if err != nil {
return
}
_, err = w.Write(buf)
}
write(p0[a:b])
write(p1[c:d])
write(p2[e:f])