Skip to content

Instantly share code, notes, and snippets.

@npat-efault
npat-efault / append_test.go
Last active October 21, 2016 06:54
Append consecutive slices, on same underlying array
package tstappend
import "testing"
const N = 8192
func appendBytes(a, b []byte) []byte {
if len(b) == 0 {
return a
}
@npat-efault
npat-efault / tokensrv.go
Last active August 29, 2015 14:09
Token server example, see http://goo.gl/QVCgcL
package main
import (
"fmt"
"time"
)
type Token struct {
token string
expires time.Time
@npat-efault
npat-efault / rot13.go
Created January 6, 2014 02:24
Rot13 en/de-coder in Go
// ROT13 reader
// See: http://en.wikipedia.org/wiki/Rot13
package main
import (
"bytes"
"io"
"os"
"strings"
)
@npat-efault
npat-efault / fibonacci.go
Created January 6, 2014 02:11
Fibonacci iterator in Go
// Fibonacci series iterator using closure
package main
import "fmt"
func fibonacci() func() int {
x, y := 0, 1
return func() int {
x, y = y, x + y
return x
@npat-efault
npat-efault / hello.go
Created January 6, 2014 01:19
Hello world in Go
// Go Hello World
package main
import "fmt"
func main() {
fmt.Println("Hello world!")
}