Skip to content

Instantly share code, notes, and snippets.

@chadlung
chadlung / main.go
Last active May 27, 2016 01:37
Introducing a race condition with Go
package main
import (
"fmt"
)
func main() {
// This code introduces a race condition!!!
finished := make(chan bool, 1)
@chadlung
chadlung / main.go
Last active June 2, 2016 07:21
Fixing a race condition with a mutex (trivial example)
package main
import (
"fmt"
"sync"
)
func main() {
finished := make(chan bool, 1)
@chadlung
chadlung / main.go
Last active February 13, 2020 22:34
An example Go (golang) REST service that uses JWT (JSON Web Tokens) and Negroni http://www.giantflyingsaucer.com/blog/?p=5994
package main
// Generate RSA signing files via shell (adjust as needed):
//
// $ openssl genrsa -out app.rsa 1024
// $ openssl rsa -in app.rsa -pubout > app.rsa.pub
//
// Code borrowed and modified from the following sources:
// https://www.youtube.com/watch?v=dgJFeqeXVKw
// https://goo.gl/ofVjK4