Skip to content
Daily Dev Tip
← Home

Backend

25 tips across 5 technologies · newest first

Unwrap errors type-safely with errors.AsType (Go 1.26)

GO

errors.AsType[E] (Go 1.26) is a generic, type-safe version of errors.As. It returns the matched error and a boolean ins…

go1.26errors
@hnooz

Sandbox filesystem access to a directory with os.Root (Go 1.24)

GO

os.Root (Go 1.24) confines all file operations to a directory: Open, Create, Stat, and friends resolve relative to the…

go1.24filesystem
@hnooz

Write custom iterators with range-over-func (Go 1.23+)

GO

Go 1.23 lets functions of type iter.Seq[V] be consumed by for range. You return a function that calls yield for each el…

go1.23iterators
@hnooz

Use b.Loop() for accurate benchmarks (Go 1.24)

GO

b.Loop() (Go 1.24) is the new benchmark loop. Beyond being cleaner than for i := 0; i < b.N; i++, it keeps setup outsid…

go1.24testing
@hnooz

Track tool dependencies in go.mod with tool directives (Go 1.24)

GO

Go 1.24 tracks executable dependencies with tool directives in go.mod, retiring the old tools.go blank-import hack. go…

go1.24modules
@hnooz

Attach request-scoped metadata with the Context facade so it flows into logs and jobs

LARAVEL

The Context facade (Laravel 11+) stores key/value data for the current request that's automatically added to every log…

observabilitylogging
@hnooz

Turn N+1 queries into errors in development with preventLazyLoading()

LARAVEL

Called in a service provider, this throws a LazyLoadingViolationException whenever a relation is accessed without being…

eloquentperformance
@hnooz

Lock down outbound HTTP in tests with preventStrayRequests()

LARAVEL

Http::fake() alone lets un-matched requests fall through to the real network, which makes tests flaky and slow and can…

testinghttp-client
@hnooz

Auto-delete stale records with the Prunable trait instead of a custom command

LARAVEL

Add Prunable and a prunable() query, and model:prune (scheduled) deletes matching rows in chunks — no bespoke cleanup c…

eloquentmaintenance
@hnooz

Use whenLoaded() in API resources to avoid firing queries during serialization

LARAVEL

Referencing $this->posts directly in a resource lazy-loads the relation for every model when it wasn't eager-loaded — a…

eloquentapi-resources
@hnooz

Throw IntrinsicException for expected errors to skip Nest's auto-logger

NESTJS

NestJS 11 added IntrinsicException: throwing it bypasses the framework's automatic error logging while still propagatin…

nestjs11exceptions
@hnooz

Validate and convert date query params at the boundary with ParseDatePipe

NESTJS

NestJS 11 ships ParseDatePipe, which validates an incoming date string and hands your handler a real Date. Parsing date…

nestjs11pipes
@hnooz

Skip the HTTP layer for workers and CLI with createApplicationContext()

NESTJS

createApplicationContext() boots the DI container without starting an HTTP server. For cron jobs, queue consumers, and…

nestjsworkers
@hnooz

Keep the SWC builder (default in Nest 11) for ~20x faster builds

NESTJS

Nest 11 defaults to the Rust-based SWC compiler, which is dramatically faster than tsc for builds and dev restarts. SWC…

nestjs11build
@hnooz

Configure a strict global ValidationPipe to strip unknown fields and coerce DTOs

NESTJS

whitelist: true removes any property not declared with a validation decorator — your defense against mass-assignment, s…

nestjsvalidation
@hnooz

Prefer asymmetric visibility over readonly when a class mutates its own state

PHP

public private(set) (PHP 8.4) makes a property readable from anywhere but writable only inside the class. readonly forb…

php8.4oop
@hnooz

Chain methods directly off constructors in PHP 8.4

PHP

PHP 8.4 allows new Foo()->method() without wrapping the instantiation in parentheses. It's a small ergonomic win that r…

php8.4syntax
@hnooz

Add #[\Override] in PHP 8.3 to catch broken method overrides at compile time

PHP

#[\Override] (PHP 8.3) tells the engine you intend to override a parent or interface method. If no matching method exis…

php8.3attributes
@hnooz

Use property hooks in PHP 8.4 to compute and validate without getter methods

PHP

PHP 8.4 lets a property define get/set hooks inline, so computed and validated values no longer need a separate method…

php8.4oop
@hnooz

Type your class constants in PHP 8.3 to lock the contract across subclasses

PHP

PHP 8.3 added type declarations for class, interface, and enum constants. Without a type, a subclass could override a c…

php8.3constants
@hnooz

Pass inline async handlers with async closures and the AsyncFn traits (Rust 1.85)

RUST

Rust 1.85 stabilized async closures (async || { ... }) and the AsyncFn/AsyncFnMut/AsyncFnOnce traits. These let higher-…

rust1.85async
@hnooz

Use native async fn in traits and drop the async-trait crate

RUST

Since Rust 1.75, async fn works directly in traits (via return-position impl Trait), giving you static dispatch with ze…

rust1.75async
@hnooz

Flatten guard clauses with let ... else

RUST

let ... else binds a pattern or diverges — the else block must return, break, continue, or panic, so control flow leave…

rustpattern-matching
@hnooz

Future-proof public types with

RUST

#[non_exhaustive] on a public enum or struct forces downstream crates to include a wildcard arm when matching, and bloc…

rustapi-design
@hnooz

Control impl Trait lifetime capture precisely with use<> (Rust 2024)

RUST

In the Rust 2024 edition, return-position impl Trait captures every in-scope generic and lifetime by default. That's us…

rust2024impl-trait
@hnooz