go

go
package upload

import (
	"errors"
	"io"
	"log"

Streaming Multipart File Uploads to Disk in Go net/http

go net-http multipart
by codesnips 3 tabs
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 webhook

import (
	"encoding/json"
	"io"
	"net/http"

Verifying and Dispatching Stripe-Style Webhooks by Event Type in Go

webhooks go hmac
by codesnips 3 tabs
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 health

import (
	"context"
	"sync"
	"time"

Concurrent Readiness Health Check Endpoint in Go with Timeouts

go health-check readiness
by codesnips 3 tabs
go
package logctx

import (
	"context"
	"log/slog"
)

Request-Scoped Structured Logging with slog and Context in Go

go logging slog
by codesnips 3 tabs
go
package authtransport

import (
	"errors"
	"net/http"
)

Injecting Auth Headers via a Custom http.RoundTripper Decorator in Go

go http middleware
by codesnips 3 tabs
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 web

import (
	"embed"
	"io/fs"
)

Serve Embedded Static Assets with embed.FS and Cache Headers in Go

go embed static-assets
by codesnips 3 tabs
go
package fetch

import (
	"context"
	"net/http"

Bounded Fan-Out With Worker Pool, errgroup, and Result Collection in Go

go concurrency goroutines
by codesnips 3 tabs
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