go

go
package observability

import (
  "time"

  "go.uber.org/zap"

Sampling logs to reduce noise during high-QPS incidents

go logging observability
by Leah Thompson 1 tab
go
package pricecache

import (
	"context"
	"sync"

Collapse Concurrent Identical Requests in Go with singleflight

go singleflight concurrency
by codesnips 3 tabs
go
package auth

import "golang.org/x/crypto/bcrypt"

func HashPassword(pw string, cost int) ([]byte, error) {
  if cost == 0 {

Password hashing with bcrypt and a calibrated cost

go security auth
by Leah Thompson 1 tab
go
package realtime

import (
  "fmt"
  "net/http"
  "time"

Server-Sent Events (SSE) with heartbeats and client cleanup

go http sse
by Leah Thompson 1 tab
go
package store

import (
  "context"

  "github.com/jackc/pgx/v5"

Row-level locking with SELECT ... FOR UPDATE in a transaction

go postgres transactions
by Leah Thompson 1 tab
go
package cleanup

import "errors"

func CloseAll(closers ...func() error) error {
  var errs []error

errors.Join for cleanup (surface multiple close failures)

go errors reliability
by Leah Thompson 1 tab
go
package limit

import (
  "context"

  "golang.org/x/sync/semaphore"

Concurrency limiting with a context-aware semaphore

go concurrency context
by Leah Thompson 1 tab
go
package migrate

import (
  "context"

  "github.com/jackc/pgx/v5/pgxpool"

Run database migrations on startup (with a guard)

go postgres migrations
by Leah Thompson 1 tab
go
package webhooks

import (
  "bytes"
  "crypto/hmac"
  "crypto/sha256"

Webhook signature verification with HMAC (timing-safe compare)

go security http
by Leah Thompson 1 tab