go

go
package health

import (
  "context"
  "net"
  "net/http"

Readiness and liveness probes with dependency checks

go http kubernetes
by Leah Thompson 1 tab
go
package domain

import "time"

type DomainEvent interface {
	EventName() string

Custom MarshalJSON for Domain Events With a Type Discriminator Envelope

go json serialization
by codesnips 3 tabs
go
package store

import (
  "context"

  sq "github.com/Masterminds/squirrel"

Safe dynamic SQL with squirrel (optional filters, stable ordering)

go sql postgres
by Leah Thompson 1 tab
go
package scheduler

import (
	"context"
	"log"
	"sync"

Graceful Cron-Style Scheduler in Go With Ticker and Context Cancellation

scheduler ticker context
by codesnips 3 tabs
go
package store

import (
	"errors"
	"fmt"
	"time"

Wrapping Errors with Context and Inspecting Them via errors.Is and errors.As in Go

errors error-handling error-wrapping
by codesnips 3 tabs
go
package observability

import (
  "context"

  "go.opentelemetry.io/otel"

OpenTelemetry tracer provider with ratio-based sampling

go observability opentelemetry
by Leah Thompson 1 tab
go
package store

import (
  "context"
  "time"

pgxpool initialization with max connections and statement timeout

go postgres pgx
by Leah Thompson 1 tab
go
package api

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

Consistent JSON responses (content-type + error envelopes)

go http json
by Leah Thompson 1 tab
go
package validate

import (
	"regexp"
	"unicode/utf8"
)

Per-Field Signup Validation Errors With a Reusable Validator in Go

go validation http
by codesnips 2 tabs
go
package middleware

import (
  "net/http"
  "sync/atomic"
)

Track in-flight requests with atomic counters

go observability concurrency
by Leah Thompson 1 tab
go
package sse

type Broker struct {
	subscribers map[chan []byte]struct{}
	subscribe   chan chan []byte
	unsubscribe chan chan []byte

Server-Sent Events in Go with http.Flusher and Context Cancellation

sse streaming http
by codesnips 3 tabs
go
package upload

import (
	"bufio"
	"errors"
	"fmt"

Streaming Multipart Upload Handler With MIME Sniffing in Go

go http multipart
by codesnips 3 tabs