This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"go/ast" | |
"go/parser" | |
"go/token" | |
"log" | |
"reflect" | |
"strings" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I saw this in a reddit post. I thought I would refactor it using a functional pattern. | |
// I don't think my refactor makes sense after noticing that this pattern is what chi suggests. | |
package main | |
import ( | |
"context" | |
"encoding/json" | |
"fmt" | |
"net/http" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl req -x509 -new -batch -nodes -sha256 -days 90 -subj "/CN=ca" -keyout ca-key.pem -out ca.pem | |
openssl req -new -sha256 -nodes -subj "/CN=localhost" -keyout server-key.pem -out server-cert.csr | |
openssl x509 -req -days 90 -sha256 -CAcreateserial -extfile <(printf "subjectAltName=DNS:127.0.0.1,DNS:0.0.0.0") -in server-cert.csr -CA ca.pem -CAkey ca-key.pem -out server-cert.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
brew update && brew cask install google-chrome visual-studio-code cloudfoundry/tap/cf-cli go iterm2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo_test | |
import ( | |
"bytes" | |
"io" | |
"io/ioutil" | |
"net/http" | |
) | |
type RoundTriper struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type Element struct { | |
Name string | |
Attributes []Attribute | |
} | |
type Attribute string | |
func (attr Attribute) IsVoid() bool { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sort "generic" | |
// https://medium.com/capital-one-tech/closures-are-the-generics-for-go-cb32021fb5b5 | |
type sorter struct { | |
len int | |
swap func(i, j int) | |
less func(i, j int) bool | |
} | |
func (x sorter) Len() int { return x.len } | |
func (x sorter) Swap(i, j int) { x.swap(i, j) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see https://play.golang.org/p/dB1ELVO8c69 | |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
) | |
const MaxNum = 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package column | |
import ( | |
"encoding/json" | |
"net/http" | |
"github.com/globalsign/mgo" | |
"github.com/julienschmidt/httprouter" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package mgocert | |
import ( | |
"context" | |
"golang.org/x/crypto/acme/autocert" | |
mgo "gopkg.in/mgo.v2" | |
) | |
type Cache struct { |