Skip to content

Instantly share code, notes, and snippets.

@mh-cbon
mh-cbon / README.md
Created May 18, 2019 10:53 — forked from eliquious/README.md
Golang OpenPGP examples

Building

go build -o goencrypt main.go

Generating Keys

@mh-cbon
mh-cbon / pull_stream.go
Last active June 15, 2017 17:12
golang stream pull
package main
import (
"errors"
"fmt"
"io"
"strings"
)
func main() {
@mh-cbon
mh-cbon / generics.go
Last active June 8, 2017 11:55
generics ?
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 / main.go
Last active June 7, 2017 07:47
golang, simple stream
package main
import (
"errors"
"fmt"
"io"
"strings"
"sync"
"time"
)
@mh-cbon
mh-cbon / main.go
Created May 16, 2017 11:01
read stdin, maybe, if it has data.
package stdinMaybe
import (
"bytes"
"errors"
"io"
"os"
"time"
)
@mh-cbon
mh-cbon / main.go
Created January 17, 2017 17:26
print go ast node without nil, nor ast.Object
package main
import (
"go/ast"
"go/parser"
"go/token"
"os"
"reflect"
)
@mh-cbon
mh-cbon / main.go
Created November 5, 2016 12:34
typed slice alias
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
Last active November 4, 2016 15:13
// data url decoding to png
package main
import (
"fmt"
"bytes"
"github.com/vincent-petithory/dataurl"
"image/png"
)
@mh-cbon
mh-cbon / main.go
Last active October 4, 2016 11:08
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)
}
@mh-cbon
mh-cbon / main.go
Created July 1, 2016 20:57
poking stream in go
package main
import (
"fmt"
"os"
// "bytes"
// "encoding/base64"
"github.com/mh-cbon/stream/stream3"
)