Skip to content

Instantly share code, notes, and snippets.

View deankarn's full-sized avatar
Coffee In -> Code Out

Dean Karn deankarn

Coffee In -> Code Out
  • Hubspot
  • /dev/tty0
View GitHub Profile
@deankarn
deankarn / response_writer.go
Created April 30, 2015 15:50
Wrapping/implementing golang's http.ResponseWriter example
// LogResponseWritter wraps the standard http.ResponseWritter allowing for more
// verbose logging
type LogResponseWritter struct {
status int
size int
http.ResponseWriter
}
// func NewMyResponseWriter(res http.ResponseWriter) *MyResponseWriter {
// // Default the status code to 200
@deankarn
deankarn / gorilla sessions random key
Created April 23, 2015 19:57
Generates a random key and encodes into base64
key := securecookie.GenerateRandomKey(64)
encoded := base64.StdEncoding.EncodeToString(key)
decoded, _ := base64.StdEncoding.DecodeString(encoded)
log.Println(key)
log.Println(encoded)
log.Println(decoded)
@deankarn
deankarn / Go Cross Compile
Last active August 29, 2015 14:15
Go Cross compile setup + build
Step #1 setup cross compiler(s) you want/need to use
cd $(go env GOROOT)/src
GOOS=linux GOARCH=amd64 ./make.bash <- GOOS=operating system - linux, darwin, windows etc... GOARCH=architechture - amd64, x86_64 386...
Step #2 navigate to go project
cd /path/of/go/project
env GOOS=linux GOARCH=amd64 go build