Skip to content
Latchkey

go vet "misuse of unbuffered os.Signal channel" in CI

The sigchanyzer analyzer flags an unbuffered channel passed to signal.Notify. Because the runtime never blocks delivering a signal, an unbuffered channel can miss signals; it must have capacity of at least one.

What this error means

go vet reports "misuse of unbuffered os.Signal channel as argument to signal.Notify".

go vet
./main.go:18:2: misuse of unbuffered os.Signal channel as argument to signal.Notify

Common causes

The signal channel has no buffer

The channel was created with make(chan os.Signal); the signal runtime does not block, so a signal can be dropped if no receiver is ready.

A buffer was sized to zero by accident

A make(chan os.Signal, 0) is equivalent to unbuffered and triggers the same diagnostic.

How to fix it

Give the channel a buffer

  1. Create the signal channel with capacity at least 1.
  2. Pass that buffered channel to signal.Notify.
  3. Re-run go vet ./....
main.go
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)

Size the buffer for the signals you watch

If you register several signals and may receive bursts, give the channel a buffer large enough to hold them.

How to prevent it

  • Always buffer signal channels (make(chan os.Signal, 1) or more).
  • Run go vet ./... in CI to catch this pattern.
  • Drain the signal channel promptly in your handler loop.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →