Skip to content

Instantly share code, notes, and snippets.

@asmedrano
asmedrano / setGOPATH.sh
Created November 8, 2015 18:48
Small GOPATH setter 2015
#!/bin/bash
export GOPATH=$(pwd):$(pwd)/vendor # make GOPATH both the local src dir and also if using GB the 'vendor' dir
export PATH=$PATH:$(pwd)/bin # add the current GOPATH bin directory to the path for convinience
package main
import "fmt"
import "encoding/json"
type My struct {
Name string
}
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@asmedrano
asmedrano / Fun with named pipes
Last active August 29, 2015 13:57
Fun with Named Pipes
Shell 1 // this will create a named pipe @ /tmp/gfifo and read from the pipe 4eva
> ./gopipe
2014/03/12 20:53:35 Created Pipe
Shell 2
> echo "ASD" > /tmp/gfifo
Shell 1 // prints bytes
> [65 83 68]
@asmedrano
asmedrano / splitfile.go
Created March 11, 2014 03:15
Split a file into several files of given bytesize. Try not to leave orphaned rows.
package main
import (
"fmt"
"os"
"bytes"
"errors"
"sync"
"path/filepath"
"strconv"
@asmedrano
asmedrano / rediswriter.go
Last active August 29, 2015 13:57
Fun with Go interfaces. In this case using io.Writer
package main
import (
"fmt"
"io"
"os"
"time"
"path/filepath"
"github.com/garyburd/redigo/redis"
)
@asmedrano
asmedrano / csvwrite.go
Created February 24, 2014 19:37
csv write in go.
package main
import(
//"fmt"
"encoding/csv"
"os"
)
func main(){
function f(){
console.log(this)
}
// window scope
f()
// object scope
var o = {
'f':f
@asmedrano
asmedrano / readcsv.go
Created February 12, 2014 15:54
Go read csv
package main
import (
"encoding/csv"
"fmt"
"io"
"os"
)
// documentation for csv is at http://golang.org/pkg/encoding/csv/
@asmedrano
asmedrano / gist:7758782
Created December 2, 2013 20:53
Flush memcached locally
echo 'flush_all' | nc localhost 11211