
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
github.com/ankur22/go-chan-ctx-timer-waitgroup-errgroup
go run ctxwithcancel.go
This shows how to use the context done channel to wait for when the done channel is explicitly closed by SIGINT (ctrl+c).
go run chanok.go
Using the ok variable read from the channel to identify when the channel was closed so we can shutdown the sender goroutine. The Channel is closed when the reader has completed reading and the channel is closed (deferred).
go run waitgrp.go
Uses WaitGroup to wait for the goroutines to complete. Still uses the ok variable from the channel to determine when the channel is closed.
go run errgrp.go
Uses errgroup instead of WaitGroup. There are three ways that wait() will unblock:
go run timer.go
This shows how to use a timer when waiting to read off a channel where the writer to the channel is slow. We may want to abort reading off a channel if it takes too long.
go run range.go
This ranges over a channel. This means we don't need to explicitly check the ok variable returned from the channel for when the channel is closed. We can't use timers though, and we also need to remember to use the default case otherwise we would block on ctx.done().
go run efficient.go
We should retrieve the done channel from the context before using it in the goroutine as this avoid the mutex lock and unlocks.
Timers can be resued instead of creating a new one when it fires, just remember to rest the timer.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.