Skip to content

Instantly share code, notes, and snippets.

View guygrigsby's full-sized avatar
💭
Thinking…

Guy J Grigsby guygrigsby

💭
Thinking…
View GitHub Profile
type Dog struct {
bark string
}
func (d *Dog) Bark() string {
return d.bark
}
func (d Dog) Bark() string {
return d.bark
type Animal struct {
}
type Dog struct {
}
type Boxer struct {
Animal
Dog
}
func TestReverse(t *testing.T) {
tests := []struct {
s string
r string
name string
}{
{"aha", "aha", "3 letter palindrome"},
{"guy", "yug", "my name"},
}
func TestReverse(t *testing.T) {
tests := []struct {
s string
r string
}{
{"aha", "aha"},
{"guy", "yug"},
}
for _, tc := range tests {
func Reverse(s string) string {
var b strings.Builder
for i := len(s) - 1; i >= 0; i-- {
b.Write([]byte{s[i]})
}
return b.String()
}
package main
import (
"net/http"
"github.com/sirupsen/logrus"
)
func main() {
mux := http.NewServeMux()
@guygrigsby
guygrigsby / closure.snippet.go
Last active September 3, 2021 03:59
Closure Example
func main() {
log := logrus.New()
apiCall := DelegateConn(log, "scheme://path/to/resource")
body := []byte("content")
_ = apiCall(body)
}
func DelegateConn(log *logrus.Logger, url string) func([]byte) error {
client := New(url)
{
"ignition": {
"version": "3.2.0"
},
"passwd": {
"users": [
{
"groups": [
"wheel",
"plugdev"
package main
import (
"context"
"fmt"
"sync"
)
func main() {
ctx := context.Background()
func main() {
log := log15.New()
mux := http.NewServeMux()
mux.Handle("/profile",
Chain(
log,
profileHandler(log),
Auth("user", "password"),
LogAccess,
),