Skip to content

Instantly share code, notes, and snippets.

View jbardin's full-sized avatar
🕵️‍♂️

James Bardin jbardin

🕵️‍♂️
  • HashiCorp
  • Boston, MA
View GitHub Profile
package main
import (
"fmt"
"go/ast"
"go/token"
"go/types"
"strings"
"golang.org/x/tools/go/analysis"

Keybase proof

I hereby claim:

  • I am jbardin on github.
  • I am jbardin (https://keybase.io/jbardin) on keybase.
  • I have a public key ASC2kvwv-QPaoxd8n3jhpt5kkrujZvjjwdH3Pr5o5Zttggo

To claim this, I am signing this object:

@jbardin
jbardin / proxy_copy.go
Last active June 28, 2023 22:12
Go TCP Proxy pattern
package proxy
import (
"io"
"log"
"net"
)
func Proxy(srvConn, cliConn *net.TCPConn) {
// channels to wait on the close event for each connection
package main
import (
"log"
"net"
"os"
"os/user"
"code.google.com/p/go.crypto/ssh"
"code.google.com/p/go.crypto/ssh/agent"
@jbardin
jbardin / utils.go
Last active February 1, 2022 11:12
// Misc Go helper functions
// most "borrowed" from Michael T. Jones
//
// Math utilities
//
// Greatest Common Divisor computed by Euclid's algorithm
func GCD(a, b int) int {
for b != 0 {
package nettimeout
import (
"net"
"time"
)
// Listener wraps a net.Listener, and gives a place to store the timeout
// parameters. On Accept, it will wrap the net.Conn with our own Conn for us.
type Listener struct {