Swap Immutable Snapshots With atomic.Pointer
Publish updated RouteTable structs via atomic.Pointer.Swap so readers holding earlier Load pointers keep reading consistent immutable snapshots.
Resolve configuration from many sources with explicit precedence and validation.
309 published examples — showing latest 48
Publish updated RouteTable structs via atomic.Pointer.Swap so readers holding earlier Load pointers keep reading consistent immutable snapshots.
Inspect env and default struct tags via reflect.StructTag.Lookup to populate typed string, int, and bool fields from a key-value map cleanly.
Combine cmp.Or fallback defaults, maps.Clone per-batch isolation, and slices.Chunk iteration to dispatch fixed-size slices cleanly.
Register custom text/template FuncMap helpers and contrast missingkey=zero against missingkey=error so absent keys either default cleanly or fail.
Cache per-Class reflection metadata lazily with java.lang.ClassValue, avoiding ClassLoader leaks while supporting explicit invalidation via remove.
Inject JDK 17 InstantSource instead of Clock when code only needs UTC instants, composing fixed, offset, and tick wrappers plus withZone adapters.
Derive monthly billing windows from YearMonth.now(Clock.fixed) so leap-year February and 31-day rollovers behave deterministically in tests.
Inspect the effective timeZone, calendar, numberingSystem, and hourCycle resolved by Intl.DateTimeFormat after applying locale extension tags.
Query runtime ICU regional defaults from Intl.Locale using getWeekInfo, getTextInfo, and getCalendars for week starts, weekends, and text direction.
Forward the third receiver argument in Reflect.get inside Proxy traps so inherited getters resolve this through the proxy rather than the raw target.
Attach preset arguments to class methods with functools.partialmethod so the descriptor protocol preserves self on instances and subclasses alike.
Implement FromStr for a ByteSize wrapper with a custom error enum separating empty strings, missing units, bad digits, and u64 overflow.
Initialize a static HashMap once with OnceLock::get_or_init for fast read-only lookups, and reject duplicate writes with OnceLock::set.
Reset a PostgreSQL sequence with ALTER SEQUENCE RESTART vs RESTART WITH, inspect pg_sequences metadata, and toggle NO CYCLE to CYCLE wraparound.
Convert timestamptz and naive timestamp against the current session TimeZone using PostgreSQL 17 AT LOCAL without hardcoding zone strings.
Enforce exact object shapes on aliased variables in generic functions with Record<Exclude<keyof Input, keyof Shape>, never> so typos fail at compile time.
Separate RequiredKeys<T> and OptionalKeys<T> using conditional mapped types over Pick<T, K>, then validate mandatory keys before merging config defaults.
Layer an override map on top of defaults so present keys win and absent keys keep their default, a common config merge shape.
Canonicalize repeated strings through unique.Make so equal values share one handle, cutting duplicate allocations in hot paths.
Read ofPattern letter counts: M counts switch number to short, full, narrow text; yy parses with a 2000-2099 base; y is year-of-era while u is the year.
Trim known prefixes and suffixes with removeprefix and removesuffix, which return the string untouched when the affix is absent instead of raising.
Parse key-value config lines with let-else so each malformed line diverges into a warning branch while the success path stays flat.
Read and write session parameters with current_setting and set_config: missing_ok returns NULL for unknown keys, and is_local scopes writes to one transaction.
Object.freeze pairs with Readonly type annotations so runtime writes throw TypeError while compile-time index writes fail before the build.
Build cmd.Env from os.Environ plus overrides so children see staged configuration, and filter secrets out of the inherited environment before spawn.
Split PATH-style environment values with filepath.SplitList, which uses the OS list separator, and rejoin them without guessing the delimiter.
ProcessBuilder.environment() inherits the parent environment and accepts overrides, so a child process receives staged config without editing global state.
Object.assign skips null and undefined sources, overwrites keys layer by layer, and mutates only its first argument, so pass {} first to keep defaults intact.
Open one handle with both read(true) and write(true), seek to a fixed record offset, and overwrite bytes in place without recreating the file.
Table-level reloptions override global autovacuum triggers for hot tables: fixed thresholds instead of size ratios, with RESET to fall back.
pg_settings exposes value, source, and context together, so you can tell session-tunable knobs from ones waiting on reload or restart.
Decode custom string fields through UnmarshalText so one method owns trimming, parsing, and rejecting invalid duration syntax.
Walk the old map for removals and value changes, the new map for additions, then sort the key slices so diff reports stay reproducible.
Multiple init functions in one file execute top to bottom after imports load, so config setup and connection warming finish before main starts.
Load text templates through template.ParseFS from any fs.FS source, so tests can use fstest.MapFS while production swaps in embed.FS untouched.
Try a prioritized list of layouts with time.Parse and wrap the last error, so timestamps arriving from different systems parse with one entry point.
Parse literal IP addresses without DNS and classify them with isLoopback, isSiteLocal, and isAnyLocal probes for validation code.
Set levels on loggers and handlers separately: a record must pass both gates, and setUseParentHandlers(false) stops duplicated parent output.
Class.getResourceAsStream strips a leading slash for classpath-root lookup, prepends the package for relative names, and returns null for missing resources.
Attach named user attributes to a file with UserDefinedFileAttributeView, read them back as bytes, and remove them with delete when superseded.
Assert nested config subsets with assert.partialDeepStrictEqual: extra keys pass, a mismatched nested value throws AssertionError with ERR_ASSERTION.
Recursively walk nested objects into dotted key paths and rebuild the tree with unflatten, with arrays kept as leaf values.
Persist progress files in the origin-private file system: getDirectory, a writable handle, and estimate() quota reporting in one flow.
Load .env configuration with process.loadEnvFile() and note the precedence rule: values already in the environment are never overridden.
Parse .env-style text with the built-in parseEnv: comments are skipped, quotes are stripped, and empty values come back as empty strings.
delete unlinks an own property so in and hasOwn both miss it, assigning undefined keeps the key, and delete on an array leaves a hole without shrinking length.
globalThis exists in browsers, workers and Node while window and global do not, so library code reads and registers runtime flags through one universal handle.
The storage event reaches every same-origin page except the one that wrote, carrying key, oldValue, and newValue; a null key means another tab called clear.
Showing 48 of 309 verified Config Management examples. Filter the full catalog by language, framework, or keyword in Explore.
Browse & filter all 309 examples in Explore →