Skip to content

Instantly share code, notes, and snippets.

View p4tin's full-sized avatar
💭
GO GO GO!!!

Paul Fortin p4tin

💭
GO GO GO!!!
View GitHub Profile
package main
import (
"context"
"log"
"net/http"
"time"
"fmt"
)
func main() {
a := NewAuthorizer()
h := WithAuth(a, http.HandlerFunc(Handle))
http.ListenAndServe("/", h)
}
const TokenContextKey = "MyAppToken"
func WithAuth(a Authorizer, next http.Handler) http.Handler {
return http.HandleFunc(func(w http.ResponseWriter, r *http.Request) {
package main
import (
"log"
"time"
"net/http"
"github.com/labstack/echo"
"github.com/labstack/echo/engine/fasthttp"
)
@p4tin
p4tin / gitkins-light.go
Last active August 16, 2016 23:01
Gitkins Light
package main
import (
"log"
"time"
"net/http"
"encoding/json"
"golang.org/x/oauth2"
"github.com/google/go-github/github"
)
package main
import (
"fmt"
"math/rand"
"time"
)
type State struct {
name string
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
var Out *os.File
package main
import (
"fmt"
"math/rand"
"os"
"sort"
"time"
)
@p4tin
p4tin / handlers_test.go
Created March 22, 2016 17:27
Testing Http Handlers in GO
package main
import (
"net/http"
"testing"
"net/http/httptest"
)
func TestHealthCheckHandler(t *testing.T) {
// Create a request to pass to our handler. We don't have any query parameters for now, so we'll
@p4tin
p4tin / text_adv-part-1.go
Last active September 24, 2024 14:38
Writing a Text Adventure Game in Go - Part 1
package main
import (
"fmt"
"math/rand"
"time"
)
type Game struct {
Welcome string
"""
Map oplog to you custom interface. To, for example, have triggers in mongo.
see example in '__main__' below
https://gist.github.com/rescommunes/4e5035242b8e4b07ff3a
"""
import logging
from time import sleep
import pickle