Skip to content

Instantly share code, notes, and snippets.

@mh-cbon
mh-cbon / main.go
Created Jul 1, 2016
poking stream in go
View main.go
package main
import (
"fmt"
"os"
// "bytes"
// "encoding/base64"
"github.com/mh-cbon/stream/stream3"
)
View main.go
package main
func main () {
get := watcher.HotTemplateReloader("a.tmpl", "b.tmpl")
// following should be thread safe, and do the hot reload of t template instance
t, err := get()
if err!=nil {
panic(err)
}
View main.go
// data url decoding to png
package main
import (
"fmt"
"bytes"
"github.com/vincent-petithory/dataurl"
"image/png"
)
@mh-cbon
mh-cbon / main.go
Created Nov 5, 2016
typed slice alias
View main.go
package main
import("fmt")
type MyStruct struct{
x string
}
type MyTypedSlice []*MyStruct
func (f *MyTypedSlice) Add(s *MyStruct) *MyTypedSlice {
@mh-cbon
mh-cbon / main.go
Created Jan 17, 2017
print go ast node without nil, nor ast.Object
View main.go
package main
import (
"go/ast"
"go/parser"
"go/token"
"os"
"reflect"
)
@mh-cbon
mh-cbon / main.go
Created May 16, 2017
read stdin, maybe, if it has data.
View main.go
package stdinMaybe
import (
"bytes"
"errors"
"io"
"os"
"time"
)
@mh-cbon
mh-cbon / main.go
Last active Jun 7, 2017
golang, simple stream
View main.go
package main
import (
"errors"
"fmt"
"io"
"strings"
"sync"
"time"
)
View generics.go
type Equer interface {
Eq(right Equer) bool
}
func Eq(left <T:BasicKind|*BasicKind|Equer>, right T) bool {
switch T.(kind){
case BasicKind:
return left == right
case *BasicKind:
return left!=nil && right!=nil && *left == *right
case Equer:
@mh-cbon
mh-cbon / pull_stream.go
Last active Jun 15, 2017
golang stream pull
View pull_stream.go
package main
import (
"errors"
"fmt"
"io"
"strings"
)
func main() {
@mh-cbon
mh-cbon / README.md
Created May 18, 2019 — forked from eliquious/README.md
Golang OpenPGP examples
View README.md

Building

go build -o goencrypt main.go

Generating Keys