Examples

Page 5 of 50

Browse code examples

rustSnippet

Spawn And Poll With try_wait

Start a child process with spawn and probe it non-blockingly via try_wait: None means still running, and wait() finally blocks for the exit status.

goSnippet

Channel Len Cap Queue Depth

len on a buffered channel reports pending items and cap reports capacity; a nil channel reports zero for both and blocks forever on receive.

goSnippet

Typed Keys Store Context Values

Attach request-scoped data with context.WithValue, keyed by an unexported struct type so package boundaries cannot collide and lookups stay type-safe.

goSnippet

Relative Paths With filepath.Rel

Turn absolute targets into root-relative paths with filepath.Rel for reports and allowlist checks, expecting the leading .. when a target escapes the root.

goSnippet

First Unique Rune Via Map

Count runes with a map, then rescan for the first rune whose count is one, returning its byte index so the winner can be sliced out of the string.